Integer value changes when using INSERT INTO in SQL Python

I am creating a table using mysql.connector in Python. When I insert an integer value into my table, SQL converts it to some other integer value. Here is my code:

cursor.execute("CREATE TABLE cleaned_data (myid VARCHAR(255), mynum INTEGER(255))")

cursor.execute("INSERT INTO cleaned_data(myid, mynum) VALUES(%s,%s)", ('mytext',25683838382092010098988))

rows = cursor.execute('select * from cleaned_data;')
for row in cursor:

Here is the output of the printed row:

('mytext', 2147483647)

Any idea what is going on? I want my table to store my integer number, even if it is huge.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

INTEGER(255) doesn’t do what you think.

Max value of an integer is 2147483647 (signed) or 4294967295 (unsigned).

See this answer for more detail What is the size of column of int(11) in mysql in bytes?

Method 2

To store numbers up to 65 digits, you can use the decimal type. For instance, for integers with 25 digits, use decimal(25,0)

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x