New submission from Simon Jagoe <azriph...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue8689>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to