Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62745

Re: Insert NULL into mySQL datetime

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'detect': 0.07; 'none:': 0.07; 'string': 0.09; 'arguments': 0.09; 'converted': 0.09; 'formatting': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; '"insert': 0.16; '(%s)"': 0.16; 'adapter': 0.16; 'escapes': 0.16; 'message- id:@4ax.com': 0.16; 'parameters,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statement.': 0.16; 'syntaxerror:': 0.16; 'tuple': 0.16; 'typeerror:': 0.16; 'wed,': 0.18; '>>>': 0.22; 'error': 0.23; 'url:home': 0.24; 'looks': 0.24; 'performing': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; "doesn't": 0.30; 'dec': 0.30; "i'm": 0.30; '"",': 0.31; 'file': 0.32; '(most': 0.33; 'something': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'step': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'break': 0.61; 'email addr:yahoo.com': 0.64; 'more': 0.64; 'invalid': 0.68; 'actually,': 0.84; 'received:108': 0.93; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Insert NULL into mySQL datetime
Date Thu, 26 Dec 2013 12:13:55 -0500
Organization IISS Elusive Unicorn
References <mailman.4605.1387931604.18130.python-list@python.org> <f5699e77-d83d-4ae5-94cf-38cf64f712d2@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-68-178-129.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4636.1388078036.18130.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1388078036 news.xs4all.nl 2844 [2001:888:2000:d::a6]:35741
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62745

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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