Mysql's insert query statement type question

Asked 2 years ago, Updated 2 years ago, 33 views

sql = """insert into tb_q (q_num, title, contents, tag, user, time)
                   values (%s,%s,%s,%s,%s,%s)"""

We've created a query statement like this The q_num variable is an integer type, but even if it is %s, is it inserted as an integer type in db?
Data inserted into db is checked.
(Even in db, the type of this field is int.)

그리고, time 변수는 문자열 형식인데 db의 해당 필드는 datetime 으로 해두었습니다. When the s % have to put the right to be a bit? It is confirmed. This data is inserted in the db

mysql python

2022-09-20 20:51

1 Answers

Yes, I was confused at first In pymysql, %s is not the s of the string, but only the purpose of specifying where you want the data to be placed.

(I forgot where I came from. I have checked the document)

Also, any data type such as datetime, int, decimal, float, etc. can be %s.


2022-09-20 20:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.