Using foreign keys in sqlite3 for Python

后端 未结 3 538
孤独总比滥情好
孤独总比滥情好 2021-02-12 23:24

I\'m writing a program that creates a sqlite3 database through python. I have one table of Authors (AuthorID, Name) and a second table of books (BookID, Title, AuthorID) I\'ve c

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-13 00:05

    Also note that if there is an active transaction, the PRAGMA foreign_keys does not work. There is no error message if you try to do so but foreign keys will still be turned off.

    If you have problems with foreign keys even after using the pragma, it may be worth an attempt to execute COMMIT once before using it.

提交回复
热议问题