NULL vs. None and MySQLdb
Geoffrey L. Wright
geoff.nospam at northernwastes.org
Tue Sep 19 08:48:49 CEST 2000
On 18 Sep 2000 19:15:07 -0700, aahz at panix.com (Aahz Maruch) wrote:
>None is the Python equivalent of NULL; what's wrong with None?
Well ... I'm passing the the result contents of str(row) strait back
to MySQL -- so that my SQL literally ends up reading something like:
INSERT INTO tableName
(column1, column2, column3, column4)
('ohNo', 'hereIt', 'comes', None)
And the problem is the MySQL chokes on the unquoted "None", whereas it
would just treat NULL as ... well ... NULL.
But I'm brand-spankin' new to both python and its SQL interaction, and
I'm _sure_ there must be some simple way of doing this. Just to get
things working I'm actually replacing all instances of None with NULL.
Given the specific nature of my data in this case, that's not a big
deal, but it is certainly a bad general solution. Plus I'm looking at
20,000 rows over 5 tables, so it's really kinda S-L-O-W right now as
well. I image that kind of regular expression substitution done
100,000 times doesn't help the performance of my little script...
More information about the Python-list