Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62745
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: Insert NULL into mySQL datetime |
| Date | 2013-12-26 12:13 -0500 |
| Organization | IISS Elusive Unicorn |
| References | <mailman.4605.1387931604.18130.python-list@python.org> <f5699e77-d83d-4ae5-94cf-38cf64f712d2@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4636.1388078036.18130.python-list@python.org> (permalink) |
On Wed, 25 Dec 2013 17:20:35 -0800 (PST), rurpy@yahoo.com declaimed the
following:
> if a is None:
> cur.execute("Insert Into mytable(datefield) VALUES(NULL))", (,))
I'm pretty sure that MySQLdb, at least, does not require the
, (,)
when there are no placeholders in the SQL statement. Might even cause an
error if the adapter doesn't detect that the tuple is empty as the last
stage of .execute() would be performing
"insert into mytable(datefield) values (NULL)" % (,)
-=-=-=-
>>> "insert into mytable(datefield) values (NULL)" % (,)
Traceback ( File "<interactive input>", line 1
"insert into mytable(datefield) values ()" % (,)
^
SyntaxError: invalid syntax
>>> "insert into mytable(datefield) values (%s)" % (,)
Traceback ( File "<interactive input>", line 1
"insert into mytable(datefield) values (%s)" % (,)
^
SyntaxError: invalid syntax
>>> "insert into mytable(datefield) values (NULL)" % (1,)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
TypeError: not all arguments converted during string formatting
>>> "insert into mytable(datefield) values (%s)" % (1,)
'insert into mytable(datefield) values (1)'
>>>
-=-=-=-
Actually, it is more likely to break on the step that escapes the
parameters, which (simplified) looks something like
>>> tuple('"%s"'%x for x in (,))
Traceback ( File "<interactive input>", line 1
tuple('"%s"'%x for x in (,))
^
SyntaxError: invalid syntax
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Insert NULL into mySQL datetime Igor Korot <ikorot01@gmail.com> - 2013-12-24 16:33 -0800
Re: Insert NULL into mySQL datetime rurpy@yahoo.com - 2013-12-25 17:20 -0800
Re: Insert NULL into mySQL datetime Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-26 12:13 -0500
Re: Insert NULL into mySQL datetime Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-12-26 19:59 +0200
csiph-web