[pypy-dev] Running pysqlite on pypy
Antonio Cuni
anto.cuni at gmail.com
Fri May 16 22:07:08 CEST 2008
Hi Gerhard, hi all,
in the last days, we have been trying to run django on pypy, using the
ctypes based implementation of pysqlite.
In doing this, we encountered a problem; we have exchanged a bit of
private mails, so I try to sum up here:
This snippet explodes when run with pysqlite-ctypes, either on cpython
or pypy-c:
>>>> from pysqlite2.dbapi2 import connect
>>>> db = connect(':memory:')
>>>> db.execute('BEGIN IMMEDIATE TRANSACTION')
<pysqlite2.dbapi2.Cursor object at 0xb7dc4f6c>
>>>> db.execute('COMMIT')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/exarkun/Scratch/Source/pysqlite3/pysqlite2/dbapi2.py",
line 315, in execute
return cur.execute(*args)
File "/home/exarkun/Scratch/Source/pysqlite3/pysqlite2/dbapi2.py",
line 483, in execute
raise self.connection._get_exception()
pysqlite2.dbapi2.OperationalError: SQL logic error or missing database
The very same thing happens on python 2.4 + pysqlite2 (non-ctypes version):
>>> from pysqlite2.dbapi2 import connect
>>> db = connect(':memory:')
>>> db.execute('BEGIN IMMEDIATE TRANSACTION')
<pysqlite2.dbapi2.Cursor object at 0xb7cb0860>
>>> db.execute('COMMIT')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
pysqlite2.dbapi2.OperationalError: cannot commit - no transaction is active
However, it works perfectly on cpython 2.5 + sqlite3:
>>> from sqlite3.dbapi2 import connect
>>> db = connect(':memory:')
>>> db.execute('BEGIN IMMEDIATE')
<sqlite3.Cursor object at 0xf7cff050>
>>> db.execute('COMMIT')
<sqlite3.Cursor object at 0xf7cff020>
Samuele pointed out that maybe it's just a difference between pysqlite2
and pysqlite3; after more digging, he changed pysqlite-ctypes to print
every SQL statement before sending it to sqlite; what he got is this:
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysqlite2 import dbapi2
>>> db = dbapi2.connect(':memory:')
>>> db.execute('BEGIN IMMEDIATE TRANSACTION')
BEGIN IMMEDIATE TRANSACTION
<pysqlite2.dbapi2.Cursor object at 0x55e90>
>>> db.execute('COMMIT')
COMMIT
COMMIT
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pysqlite2/dbapi2.py", line 318, in execute
return cur.execute(*args)
File "pysqlite2/dbapi2.py", line 489, in execute
raise self.connection._get_exception()
pysqlite2.dbapi2.OperationalError: SQL logic error or missing database
The double COMMIT is probably causing the problem; not sure if it's a
bug in pysqlite-ctypes or an expected behavior.
Gerhard, what do you think about all of this? What's the best way to solve?
ciao,
Anto
More information about the Pypy-dev
mailing list