[SQL] Right way to set a variable to NULL?
nospam at nospam.com
Fri Dec 26 21:33:32 CET 2008
I use regexes to extract information from a text file. Some of the
records don't have e-mails or www addresses, so those must match Null
in SQL, but None doesn't work as expected:
web = itemmatch.group(1).strip()
web = None
sql = 'INSERT INTO mytable (name,address,web,mail) VALUES
("%s","%s","%s","%s","%s")' % (name,address,web,mail)
Is there a better way in Python to have a variable match NULL than
building the SQL query step by step?
More information about the Python-list