0

Trying to insert into a null value to MySql table using python. Below is the code executed

sql="""insert into db.table_name (int_column, column2) values (None, 'test')"""
cursor.execute(sql)

while running getting below error

mysql.connector.errors.ProgrammingError: 1054 (42s22) : Unknown column 'None' in 'field list'

Tried this out with reference to this solution

Raju
  • 448
  • 1
  • 9
  • 24

1 Answers1

2

try the following, replace your none with null

sql="""insert into db.table_name (int_column, column2) values (null, 'test')"""
cursor.execute(sql)
zealous
  • 7,336
  • 4
  • 16
  • 36