[New-bugs-announce] [issue15754] Traceback message not returning SQLite check constraint details

John Taylor report at bugs.python.org
Tue Aug 21 16:36:27 CEST 2012


New submission from John Taylor:

According to:
http://www.sqlite.org/releaselog/3_7_12.html

SQLite has the ability to, "Report the name of specific CHECK constraints that fail."

CPython 3.3.0b2 which uses SQLite version 3.7.12 does not report which constraint failed.
--
import platform, sqlite3

print("Platform : %s %s" % (platform.python_implementation(),platform.python_version()))
print("SQLite   : %s" % (sqlite3.sqlite_version))
print()

tbl="""\
create table test1 (
        db_insert_date       timestamp,
        check( cast(substr(db_insert_date,1,4) as integer) >= 2000 and cast(substr(db_insert_date,1,4) as integer) <= 2025),
        check( cast(substr(db_insert_date,6,2) as integer) >= 1    and cast(substr(db_insert_date,6,2) as integer) <= 12),
        check( cast(substr(db_insert_date,9,2) as integer) >= 1    and cast(substr(db_insert_date,9,2) as integer) <= 31)
)
"""

conn = sqlite3.connect(":memory:")
c = conn.cursor()
c.execute(tbl)

query = "insert into test1 values( ? )"
c.execute(query, ("2012-08-20", ) )
conn.commit() # this works

c.execute(query, ("2012-18-20", ) )
conn.commit() # returns: sqlite3.IntegrityError: constraint failed (but which constraint?)

"""
Traceback (most recent call last):
  File "C:bug.py", line 34, in <module>
    c.execute(query, ("2012-18-20", ) )
sqlite3.IntegrityError: constraint failed
"""

----------
components: Extension Modules
messages: 168777
nosy: ghaering, jftuga
priority: normal
severity: normal
status: open
title: Traceback message not returning SQLite check constraint details
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15754>
_______________________________________


More information about the New-bugs-announce mailing list