[New-bugs-announce] [issue22382] sqlite3 connection built from apsw connection should raise IntegrityError, not DatabaseError
william tonkin
report at bugs.python.org
Wed Sep 10 20:30:15 CEST 2014
New submission from william tonkin:
python
Python 2.7.6 (default, Dec 23 2013, 13:16:30)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
-----
test script
-----
import apsw
import sqlite3
print 'sqlite3.version:', sqlite3.version
print 'sqlite3.sqlite_version:', sqlite3.sqlite_version
print 'apsw.apswversion:', apsw.apswversion()
sqlite3_not_from_apsw = sqlite3.connect(':memory:')
apsw_conn = apsw.Connection(':memory:')
sqlite3_from_apsw = sqlite3.connect(apsw_conn)
cursor_not_from_apsw = sqlite3_not_from_apsw.cursor()
cursor_from_apsw = sqlite3_from_apsw.cursor()
sqlite3_not_from_apsw.execute(
"create table foo ( a timestamp check(datetime(a) is not null))")
try:
sqlite3_not_from_apsw.execute(
"insert into foo values (?)", ('',))
except sqlite3.DatabaseError as foo:
print 'not from apsw, repr(foo)', repr(foo)
sqlite3_from_apsw.execute(
"create table foo ( a timestamp check(datetime(a) is not null))")
try:
sqlite3_from_apsw.execute(
"insert into foo values (?)", ('',))
except sqlite3.DatabaseError as foo:
print 'from apsw, repr(foo)', repr(foo)
-------------
output:
sqlite3.version: 2.6.0
sqlite3.sqlite_version: 3.8.2
apsw.apswversion: 3.8.2-r1
not from apsw, repr(foo) IntegrityError('CHECK constraint failed: foo',)
from apsw, repr(foo) DatabaseError('CHECK constraint failed: foo',)
--------
Note that when the sqlite3 connection is built from an apsw connection the insert statement that violates the check constraint raises 'DatabaseError' and not 'IntegrityError'.
----------
messages: 226704
nosy: wtonkin
priority: normal
severity: normal
status: open
title: sqlite3 connection built from apsw connection should raise IntegrityError, not DatabaseError
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22382>
_______________________________________
More information about the New-bugs-announce
mailing list