[New-bugs-announce] [issue8689] sqlite3 parameter substitution breaks with multiple parameters
Simon Jagoe
report at bugs.python.org
Tue May 11 18:27:02 CEST 2010
New submission from Simon Jagoe <azriphale at gmail.com>:
I have been using sqlalchemy and sqlamp in a project for a while with Python 2.5.x and Python 2.6.4. With a recent upgrade to Python 2.6.5 (on Ubuntu Lucid Lynx), a particular operation began to fail when using sqlite.
I have tracked this to using the sqlite3 module and multiple parameter substitution. See below for a simple test case.
Set up the database:
>>> import sqlite3
>>> conn = sqlite3.connect('test.sqlite3')
>>> c = conn.cursor()
>>> c.execute('create table test (col integer)')
>>> c.execute('insert into test values (1)')
>>> conn.commit()
Actual result:
>>> c.execute('SELECT coalesce(max(test.col), ?) + ? AS col FROM test', (0, 1))
>>> c.fetchone()
(None,)
Expected result:
>>> c.execute('SELECT coalesce(max(test.col), ?) + ? AS col FROM test', (0, 1))
>>> c.fetchone()
(2,)
The expected result can be simulated like this:
>>> c.execute('SELECT coalesce(max(test.col), 0) + 1 AS col FROM test')
>>> c.fetchone()
(2,)
----------
messages: 105525
nosy: azriphale
priority: normal
severity: normal
status: open
title: sqlite3 parameter substitution breaks with multiple parameters
versions: Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8689>
_______________________________________
More information about the New-bugs-announce
mailing list