0

I'm new to the Mysql,so i'm getting the problem while passing the null value to date field from the python script calling the procedure.Can you please help me out

I have table in mysql db_test with fields name and date,date column allows null value.

i call the procedure from python like these

cursor.execute("CALL date_insert(%s,%s) ;" %('john',None))

But it shows an error

Error No:1292 Incorrect value 'None' for the date column
0

3 Answers 3

2

Try:

cursor.execute("CALL date_insert(%s,%s) ;" % ('john', 'NULL')

Or

cursor.execute("CALL date_insert(%s,%s) ;" % ('john', '\\N')

You might even need:

cursor.execute('CALL date_insert("%s", %s) ;' % ('john', 'NULL')

Just remember that while they are used similarly the various languages:

None, NULL, Null, null, NIL, 0, void, void *, '', "". <>, ?

are not the same and not necessarily interchangeable.

Sign up to request clarification or add additional context in comments.

2 Comments

I try with Null instead of None as your suggestion but still i getting the error as (1292, "Incorrect date value: 'Null' for column 'amc_date' at row 1")
@Srilatha NULL is not the same as Null - Many languages are case dependent especially for "special" or "reserved" names.
0

Try NULL instead of None for MYSQL:

cursor.execute("CALL date_insert(%s,%s) ;" %('john','NULL'))

Comments

0

Use:

cursor.execute("CALL date_insert(%s,%s) ;" % ('john', 'NULL')

None is the Python's way to represent empty objects. MySQL do not have any idea what it is. Instead,MySQL uses 'NULL' for representing empty values.

Refer "MySQL - Working with Null" for more details.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.