[SQL] Right way to set a variable to NULL?
Martin
martin at marcher.name
Fri Dec 26 15:42:34 EST 2008
Hi,
I'd create a simple wrapper object
class MailAddress(object):
def __init__(self, address=None):
self.address = address
def __str__(self):
if address:
return self.adress
return "NULL"
you can keep most of your code just replace the original instantiation
of the mail str-instance with the MailAddress
This is just scratched up quickly. Hope it helps
Martin
2008/12/26 Gilles Ganault <nospam at nospam.com>:
> 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?
>
> Thank you.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://soup.alt.delete.co.at
http://www.xing.com/profile/Martin_Marcher
http://www.linkedin.com/in/martinmarcher
You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
More information about the Python-list
mailing list