Pymysql inserts a numeric string into the database and does not report an error and does not successfully ask for help.

insert but the data is a number, which is stored in the database as a string, and the corresponding field in the database is also of string type

The

python statement goes like this:

sql = "insert into uhaoma343 (riqi,uhaoma) values({},{})".format(riqi"""+ uhaoma +""")

-sharp """+ uhaoma +""" 

the data goes like this:

insert into uhaoma343 (riqi,uhaoma) values(20180502,"765446 4643556 924612 065320 669676 5345469 90532 032347 331238 081245329 422349 294233 062356 042111 1912540 954391 5234531 991230 321242 64631 102345 316767 003456 50679 353244 5234178 381234 674327 095645 177756 2453483 0345260 7923459 272341 323598 951241 076828 1721346 3213543 2664550 1134876 831289")

everything seems to be normal. The point is that after insertion, the id returns, and the database auto-increment key also increases, but there is no data (it is known that the self-increment increase is due to the self-increment number shown after manual insertion)

there is nothing empty in the database! This statement executes everything manually in mysql!

whether you know all the methods used are really inexplicable

Thank you for your help.

Mar.09,2021

Strings in

sql should be in single quotation marks

you try this


riqi=1
uhaoma="fdkflfd sdfldskjfl sdfldsjfl "

sql = 'insert into uhaoma343 (riqi,uhaoma) values({},{})'.format(riqi, '\''+ uhaoma+'\'' )

print(sql)

the generated SQL is in the form of

insert into uhaoma343 (riqi,uhaoma) values(1,'fdkflfd sdfldskjfl sdfldsjfl ')

requires python to call commit. Refer to the tutorials on the web. Or refer to the official document and use the with statement to connect to the database.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea7cf0-47c4d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea7cf0-47c4d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?