Why aren't my sqlite3 foreign keys working?

前端 未结 2 1106
我寻月下人不归
我寻月下人不归 2021-01-05 07:58

I run the following code from a python interpreter, and expect the insert statement to fail and throw some kind of exception. But it\'s not happening:

Python         


        
2条回答
  •  礼貌的吻别
    2021-01-05 08:11

    Working foreign key support in SQLite is very new -- it was only released in 3.6.19 on October 14th. Are you sure you're using SQLite 3.6.19 or later?

    Check the sqlite_version constant in the sqlite3 module. E.g. on a Mac OS X 10.6 system with the default python/sqlite install:

    >>> import sqlite3
    >>> sqlite3.sqlite_version
    '3.6.12'
    >>> 
    

提交回复
热议问题