## mysql – How to punctuate an INSERT statement that uses FROM_UNIXTIME

In one Python environment, I have the following variable:

``````post_time_ms="1581546697000"
``````

which is a Unix style time with milliseconds.

In my table, "created_date_time" is defined as a datetime column.

I am trying to use an INSERT statement from the form:

``````sql_insert_query = "INSERT INTO myTable (id_string, text,
created_date_time) VALUES ('identifier', 'text_content',
FROM_UNIXTIME('post_time/1000')"
``````

I can't understand how I'm supposed to punctuate this. If I execute the query as shown above, I get:

``````"Failed to insert record 1292 (22007): Truncated incorrect DECIMAL value: 'tweet_post_time/1000'
``````

I have tried every variant of single quotes / no quotes I can think of, but I still get errors.

For example, if I do:

``````sql_insert_query = "INSERT INTO myTable (id_string, text,
created_date_time) VALUES ('identifier', 'text_content',
FROM_UNIXTIME('post_time'/1000)"
``````

I receive:

``````Failed to insert record 1292 (22007): Truncated incorrect DOUBLE value: 'tweet_post_time'
``````

I went so far as to try to convert the Unix style value "1581546697000" as follows:

``````post_time_mysql = datetime.fromtimestamp(int(post_time)/1000)
``````

then:

``````sql_insert_query = "INSERT INTO myTable (id_string, text,
created_date_time) VALUES ('identifier', 'text_content',
'post_time_mysql')"
``````

and although

``````print(post_time_mysql)
``````

outputs "2020-02-14 09:25:28",

I'm still getting this error for the above query:

``````Failed to insert record 1292 (22007): Incorrect datetime value: 'post_time_mysql' for column `myDatabase`.`myTable`.`created_date_time` at row 1
``````

Any ideas / suggestions?

## html – Download the income statement from a web page using BeautifulSoup

I'm trying to grab the results table from McDonald & # 39; s Corporation (MCD) "https://finance.yahoo.com/quote/MCD/financials?p=MCD". I used a nice soup. The html is downloaded, but there does not seem to be a typical "tr", "td" tag for the income statement table.

my codes:

``````url="https://finance.yahoo.com/quote/MCD/financials?p=MCD"
result = requests.get(url)
result.raise_for_status()
result.encoding = "utf-8"

src = result.content
soup = BeautifulSoup(src, 'lxml')
#soup = BeautifulSoup(src, 'html5lib')
#print(soup.prettify())
print(soup)

with open('soup.txt','w') as f:
f.write(str(src))

array = ()
for tr_tag in soup.find_all('tr'):
b_tag = tr_tag.find_all('td')
array.append(b_tag)
print(array)
``````

## The subquery (using IN) will execute multiple times for the update statement (SQL Server 2017)

When an update statement updates the value returned by a subquery – will the subquery be executed for each row?

``````UPDATE a
SET DM = 1
FROM TableA a
WHERE a.ID NOT IN (SELECT DISTINCT ID FROM TableA WHERE DM = 1)
``````

Column ID is not unique in the table, so we can have multiple rows for one ID

Will it always update all rows from ID to DM = 1 or sometimes just one?

## functions – get_current_user_id () always returns 0 in the if else statement

I am trying to get the logged in user ID after the if else statement, but I always return 0. When I put get_current_user_id () before it gives the Correct user ID. How can I make it work in the if statement?

``````
``````

## complexity theory – Are there NP-hard problems for which the following statement is true:

You confuse NP and NP-hard in a few places. For example, let $$A$$ be the problem of deciding ATL *, which is 2EXPTIME-complete. $$A$$ is NP-hard and polynomial many times reduced to its complement, but is neither in NP nor in co-NP by the time hierarchy theorem.

Recall that an NP-complete problem is a problem that is in NP and that is NP-difficult. For each NP-complete problem $$A$$, we have that $$A$$ is in co-NP if and only if NP = co-NP. Make sure you understand why: try to prove the if direction (easy) and the if direction only (requires a little more thought). Here's proof of the only if direction, if you're stuck:

Suppose that there is an NP-complete problem X which is in co-NP. Since all NP problems can be reduced to X, it follows that for each NP problem, we can build a non-deterministic Turing machine which decides its complement in polynomial time, that is, – say NP ⊆ co-NP. It follows that the set of problem complements in NP is a subset of the set of problem complements in co-NP, i.e. co-NP ⊆ NP. So co-NP = NP. (from Wikipedia)

## postgresql – The number violated the unique constraint caused by the INSERT statement

I would like to add lines of `table2` in `table1` and see how many conflicts like "duplicate key value violate unique constraint" result in PostgreSQL. `pkey` is a primary key, so there is a unique constraint. Unfortunately and apparently, `conflict_action` does not allow incrementing a counter.

``````INSERT INTO table1 (pkey, col1, col2)
SELECT pkey, col1, col2 FROM table2
ON CONFLICT ...;
``````

So is there another (elegant) way to solve this problem by calculating or retrieving this number?

## mysql – Configure the description statement

I wonder if there is a way to configure what the `describe` reporting reports for the `type` column? Specifically, is there a way to turn off `int` East `unsigned` or not? Currently using MySQL 8.

As an example, I would like this:

``````+-------------+-------------------+------+-----+---------+-------+
| Field       | Type              | Null | Key | Default | Extra |
+-------------+-------------------+------+-----+---------+-------+
| id          | int unsigned      | NO   | PRI | 0       |       |
| firstname   | varchar(255)      | YES  |     | NULL    |       |
+-------------+-------------------+------+-----+---------+-------+
``````

to declare as follows when in use `describe `

``` :+-------------+-------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------+------+-----+---------+-------+ | id | int | NO | PRI | 0 | | | firstname | varchar(255) | YES | | NULL | | +-------------+-------------------+------+-----+---------+-------+ jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":180231,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P180231\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/mysql-configure-the-description-statement/" }, "headline": "mysql - Configure the description statement", "url": "https://newproxylists.com/mysql-configure-the-description-statement/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2020-01-19T08:00:41+02:00", "dateModified": "2020-01-19T08:00:41+02:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "13" } } Author AdminPosted on January 19, 2020Tags configure, Description, MySQL, statement linear algebra – The reverse of the statement is true? Two linear systems using the same set of variables are equivalent if each of the equations of the second system can be derived algebraically from the equations of the first system, and vice versa. Two systems are equivalent if the two are incompatible or if each the equation of each of them is a linear combination of the equations of L & # 39; other. It follows that two linear systems are equivalent if and only if they have the same set of solutions. jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":180087,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P180087\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/linear-algebra-the-reverse-of-the-statement-is-true/" }, "headline": "linear algebra - The reverse of the statement is true?", "url": "https://newproxylists.com/linear-algebra-the-reverse-of-the-statement-is-true/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2020-01-18T20:09:45+02:00", "dateModified": "2020-01-18T20:09:45+02:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "48" } } Author AdminPosted on January 18, 2020Tags algebra, linear, reverse, statement, True computed column formula – Long SharePoint If statement OR itself is a function, see here. for example, =IF(OR((thing1)=(thing2),(thing3)=(thing4),(thing5)=(thing6)), "ValueToShowIfAtLeastOneOfThoseAreTrue", "ValueToShowIfNoneAreTrue")) Basically the OR The function takes up to 30 different Boolean instruction parameters and returns TRUE if one or more of these statements TRUEand returns FALSE if none of the declarations are TRUE. (there is a AND() function that returns only TRUE if all the declarations provided are TRUE. You can also nest IF statements, so the first parameter is your Boolean parameter (which itself can be an OR or AND or another Boolean function), the second parameter is what to return when the first parameter is TRUE, and the third parameter is what to return when this first parameter is FALSE, and this third parameter can also be a nested SI to evaluate if the first has been FALSE, etc. Based on your comment, the following example of the OR may be closer to what you are trying to do. =IF(OR((DeptID)=101,(DeptID)=102,(DeptID)=103),"Bob", IF(OR((DeptID)=211,(DeptID)=212,(DeptID)=213), "TOD", IF(OR((DeptID)=641,(DeptID)=642,(DeptID)=643), "Sara", "Unknown"))) Also note that if your service IDs are numeric and are sequences, you use more and less than rather than equal, for example IF (AND ((DeptID)> = 101, (DeptID) <= 103), "Bob", etc. But this only works if all the departments belonging to one person are in sequential order. This is an old article, but still a great starting point for learning SharePoint formulas: https://support.office.com/en-us/article/examples-of-common-formulas -in-sharepoint-lists-d81f5f21-2b4e -45ce-b170-bf7ebf6988b3 jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":179967,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P179967\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/computed-column-formula-long-sharepoint-if-statement/" }, "headline": "computed column formula - Long SharePoint If statement", "url": "https://newproxylists.com/computed-column-formula-long-sharepoint-if-statement/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2020-01-18T12:17:34+02:00", "dateModified": "2020-01-18T12:17:34+02:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "5" } } Author AdminPosted on January 18, 2020Tags column, Computed, formula, long, sharepoint, statement mysql – The generated DDL does not match the CREATE TABLE statement I am using MySQL with the InnoDB engine. I create a new table that contains a foreign key, for example: CREATE TABLE rooms ( id INTEGER NOT NULL AUTO_INCREMENT, my_id VARCHAR(15), house_id INTEGER, PRIMARY KEY (id), FOREIGN KEY(house_id) REFERENCES houses (id) ON DELETE CASCADE ) When I use a DB tool such as DBeaver to see the details of my database and this table, I see that my foreign key house_id miss it ON DELETE CASCADE setting. DBeaver also displays the DDL for this table as follows: CREATE TABLE `rooms` ( `id` int(11) NOT NULL AUTO_INCREMENT, `my_id` varchar(15) COLLATE utf8mb4_general_ci DEFAULT NULL, `house_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `house_id` (`house_id`), CONSTRAINT `rooms_ibfk_1` FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci Why does DDL have the extra line KEY 'house_id' ('house_id').? This additional line also shows my foreign key 2 house_id columns in my DBeaver table viewer. If I get rid of it, my ON DELETE CASCADE is adjusted correctly. I am using an ORM so I have no control over the CREATE TABLE statement, so I'm just trying to at least understand what's going on here. thank you, jQuery(document).ready(function() {jQuery.ajax({type: "POST",url : rating_form_script.ajaxurl,data : { action : "display_rating_form_ajax", args : {"id":1,"post_id":179138,"comment_id":0,"custom_id":"0","user_id":0,"term_id":0,"title":false,"score":true,"total":true,"stats":true,"user_stats":false,"tooltip":true,"result":true,"rich_snippet":true,"is_widget":false,"state":"","before_content":"","after_content":"","rates":"rating,ratings","txt_score":"%1\$s\/%2\$s"} }, success : function(data) { jQuery("body").find("[data-id=\"RFR1P179138\"]").html(data); }});}); { "@context": "http://schema.org", "@type": "Article", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://newproxylists.com/mysql-the-generated-ddl-does-not-match-the-create-table-statement/" }, "headline": "mysql - The generated DDL does not match the CREATE TABLE statement", "url": "https://newproxylists.com/mysql-the-generated-ddl-does-not-match-the-create-table-statement/", "author": { "@type": "Person", "name":"Admin" }, "publisher": { "@type": "Organization", "name": "New and Fresh Private + Public Proxies Lists Everyday!", "logo": { "@type": "ImageObject", "url": " ", "width": "", "height": "" } }, "datePublished": "2020-01-16T00:07:27+02:00", "dateModified": "2020-01-16T00:07:27+02:00", "aggregateRating": { "@type": "AggregateRating", "bestRating": "5", "worstRating": "1", "ratingValue": "5", "ratingCount": "12" } } Author AdminPosted on January 16, 2020Tags create, DDL, generated, match, MySQL, statement, table Posts navigation Page 1 Page 2 … Page 19 Next page New and Fresh Private + Public Proxies Lists Everyday! Proudly powered by WordPress DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123 <!-- var sc_project=11212449; var sc_security="38b03c22"; var sc_invisible=1; var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www."); //--> /* <![CDATA[ */ var rating_form_script = {"ajaxurl":"https:\/\/newproxylists.com\/wp-admin\/admin-ajax.php"}; /* ]]> */ /* <![CDATA[ */ var screenReaderText = {"expand":"expand child menu","collapse":"collapse child menu"}; /* ]]> */ ```