MySQLdb Warning: Field x doesn't have a default value

Today while I was working on a Python program that uses mysql database, I got a new type of warning while inserting data into a table:

/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py:206: Warning: Field 'id' doesn't have a default value
  r = r + self.execute(query, a)

Then I looked into the mysql table and found that the field 'id' was supposed to have a default value (primary key, auto increment). But somehow it didn't have. That was the reason of the warning and it got vanished after I fixed the table.

Hope my experience will save your time if you get into this problem. Happy coding! :)

Comments

Popular posts from this blog

Strip HTML tags using Python

lambda magic to find prime numbers

Convert text to ASCII and ASCII to text - Python code