mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
ignore=True argument for add_foreign_key, closes #112
Also --ignore for add-foreign-key command Plus table.add_foreign_key(...) now returns self, allowing more chaining
This commit is contained in:
parent
ecb50c8f76
commit
e23eedb4ce
6 changed files with 48 additions and 9 deletions
|
|
@ -858,6 +858,12 @@ The ``table.add_foreign_key(column, other_table, other_column)`` method takes th
|
|||
|
||||
This method first checks that the specified foreign key references tables and columns that exist and does not clash with an existing foreign key. It will raise a ``sqlite_utils.db.AlterError`` exception if these checks fail.
|
||||
|
||||
To ignore the case where the key already exists, use ``ignore=True``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
db["books"].add_foreign_key("author_id", "authors", "id", ignore=True)
|
||||
|
||||
.. _python_api_add_foreign_keys:
|
||||
|
||||
Adding multiple foreign key constraints at once
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue