How to solve the problem that the string numbers are saved in the database and all of them are killed from the front to the zero?

some data are like this: 1186486, 0215648, 00064876, mysql stores data to columns of char type,
data is stored in front of 0, all columns are killed. How to solve

the short ones are preceded by 0, and the data is a string in python and does not kill before 0.
before manual modification with database software, there can be 0

.

I wonder about this

Thank you

Mar.07,2021

char type in mysql, leading 0 is not automatically removed

check the sql statements in the log to see if there is data processing in the application layer.


your orm method is still passed naked sql. The former looks at the field type defined by your model, Column (INTEGER (), nullable=True)
the latter depends on whether you format the symbol % s with quotation marks INSET INTO.. VALUES ('% s') . From the description, when you generate sql, the value of the data is passed as int, so there should be something wrong on the python side.


the solution is very simple.
just take it out and add 0.
back-end processing. Front-end processing can be
when inserting into the database, adding string numbers in quotation marks indicates the string. Mysql will not leave out

.
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-1eab8b6-2065.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-1eab8b6-2065.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?