mysql – How to punctuate an INSERT statement that uses FROM_UNIXTIME

In one Python environment, I have the following variable:


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',

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',

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)


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

and although


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) "". 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:

result = requests.get(url)
result.encoding = "utf-8"

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

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

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

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?

SET DM = 1
FROM TableA a 

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

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    |       |

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.

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: -in-sharepoint-lists-d81f5f21-2b4e -45ce-b170-bf7ebf6988b3

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:

    my_id VARCHAR(15), 
    house_id INTEGER, 
    PRIMARY KEY (id), 

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` (
  `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,