On Mon, 2013-05-20 at 10:49 -0500, Carl Karsten wrote: > On Mon, May 20, 2013 at 9:12 AM, Daniele Varrazzo > <daniele.varra...@gmail.com> wrote: > > > > In [6]: cur.execute("insert into test values (?, 'wat?')", ('hi')) > > --------------------------------------------------------------------------- > > ProgrammingError Traceback (most recent call last) > > /home/piro/src/qmarkpg/<ipython-input-6-b8a3105dc710> in <module>() > > ----> 1 cur.execute("insert into test values (?, 'wat?')", ('hi')) > > > > ProgrammingError: Incorrect number of bindings supplied. The current > > statement uses 1, and there are 2 supplied. > > Shouldn't ('hi') be ('hi',) ? > > >>> cur.execute("insert into test values (?, 'wat?')", ('hi',)) > <sqlite3.Cursor object at 0x7f28919eb570>
Oh, right, sqlite (the library, not the python module) can deal with a question mark in a string ok. Wrong example then. Grepping for '?' in the _sqlite directory in Python source suggests that literals ? are not looked for anywhere; this implies that the module doesn't process them before passing the string to the client library (that in the sqlite specific case is *the* database, in client-server libraries this is not the case but I don't have any handy to test). If any module wanted to support a placeholder different than the native one would find the need to parse the query string, which I don't think is a reasonable thing to ask to a client library. -- Daniele _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig