Python, Mysql, insert NULL

deelan ggg at zzz.it
Wed Oct 5 14:17:20 CEST 2005


Python_it wrote:
> I know how to insert values in a database.
> That's not my problem!
> My problem is how i insert NULL values in de mysql-database.
> None is een object in Python and NULL not.
> None is not converted to NULL?
> Table shows None and not NULL!

None is converted to mysql's NULL and vice versa. It sounds
you are passing the *string* "None" to mysql, with it isn't
the same thing.

Adapting the Laszlo's example already posted:

cursor.execute("insert into tablename(fieldname) values (%s)", [None])

HTH.

-- 
deelan, #1 fan of adriana lima!
<http://www.deelan.com/>







More information about the Python-list mailing list