Commit graph

222 commits

Author SHA1 Message Date
Simon Willison
617e6f070c enable_fts(..., tokenize=X) parameter, refs #130 2020-08-01 13:40:36 -07:00
Thomas Sibley
ae4593316c Add insert --truncate option
Deletes all rows in the table (if it exists) before inserting new rows.
SQLite doesn't implement a TRUNCATE TABLE statement but does optimize an
unqualified DELETE FROM.

This can be handy if you want to refresh the entire contents of a table
but a) don't have a PK (so can't use --replace), b) don't want the table
to disappear (even briefly) for other connections, and c) have to handle
records that used to exist being deleted.

Ideally the replacement of rows would appear instantaneous to other
connections by putting the DELETE + INSERT in a transaction, but this is
very difficult without breaking other code as the current transaction
handling is inconsistent and non-systematic.  There exists the
possibility for the DELETE to succeed but the INSERT to fail, leaving an
empty table.  This is not much worse, however, than the current
possibility of one chunked INSERT succeeding and being committed while
the next chunked INSERT fails, leaving a partially complete operation.
2020-07-08 10:26:20 -07:00
Simon Willison
fbeb61e49c
Documentation for table.pks, closes #116 2020-06-23 14:03:13 -07:00
Simon Willison
78264b738c Removed docs for feature I decided not to implement, refs #27 2020-05-03 08:25:21 -07:00
Simon Willison
9f6085b4e4 create-table --ignore and --replace, refs #27 2020-05-03 08:24:39 -07:00
Simon Willison
79541d3a6d Release 2.7.2, refs #106 2020-05-02 09:05:27 -07:00
Simon Willison
5c1df4e306 replace=True and ignore=True parameters for create_view(), closes #106 2020-05-02 09:02:04 -07:00
Simon Willison
2ab62bcd54 New columns= parameter for over-riding column types, closes #100 2020-04-17 16:53:25 -07:00
Simon Willison
31d3df0f79
Typo fix 2020-04-16 15:21:40 -07:00
Simon Willison
125c625fbc .rows_where(..., order_by=) argument, closes #76 2020-04-15 20:12:55 -07:00
Simon Willison
7e4b9997c2 Database(..., recreate=True) option, refs #97 2020-04-12 20:46:51 -07:00
Simon Willison
43f1c6ab4e
Documentation for NotFoundError 2020-03-06 15:08:21 -06:00
Simon Willison
f9473ace14 disable-fts and .disable_fts(), closes #88 2020-02-26 20:40:35 -08:00
Simon Willison
0eda638d81 table.exists() now a documented method, closes #83 2020-02-08 15:56:03 -08:00
Simon Willison
de76168be5 Docs for suggest_column_types, closes #81 2020-02-01 13:55:13 -08:00
Simon Willison
e8b2b7383b
New conversions= feature, closes #77
Pull request: #78
2020-01-30 16:24:30 -08:00
Simon Willison
9f47e8b9a4 Documentation for new upsert v.s insert-replace
Refs #66
2019-12-30 05:29:23 +00:00
Simon Willison
9262c3e7c0
Corrected Database(memory=True) documentation 2019-12-18 09:00:36 +00:00
Simon Willison
a0a65f9a64 Release 1.12 2019-11-04 08:28:52 -08:00
Simon Willison
169ea455fc Added table.delete_where(), closes #62 2019-11-04 08:18:06 -08:00
Simon Willison
19073d6d97 Added table.delete(pk) method, refs #62 2019-11-04 08:08:01 -08:00
Simon Willison
d5e1f8ac77 Release 1.11 2019-09-02 17:58:41 -07:00
Simon Willison
3a4dddaca2 Documentation for create-triggers, refs #57 2019-09-02 17:10:26 -07:00
Simon Willison
2ca63e3b2d
db.triggers and table.triggers introspection (#60)
Closes #59
2019-09-02 17:09:41 -07:00
Simon Willison
68a5cb1b8e
Corrected .table_views() -> .view_names() 2019-08-26 07:03:22 +02:00
Simon Willison
9faa982226
Ability to introspect and run queries against views (#55)
* db.views_names() method and and db.views property
* Separate View and Table classes, both subclassing new Queryable class
* view.drop() method
* Updated documentation
2019-08-23 15:19:41 +03:00
Simon Willison
0e7b461eb3
Fixed typo 2019-08-04 07:13:31 +03:00
Simon Willison
243bcaa1ac Documentation for .m2m() table method 2019-08-04 05:29:19 +03:00
Simon Willison
5986083746 Documentation for table.update() method 2019-07-28 18:03:44 +03:00
Simon Willison
535a5ea476 Documentation and tests for table.drop() method 2019-07-28 14:57:02 +03:00
Simon Willison
941d281aee
extracts= table parameter, closes #46 2019-07-23 10:00:42 -07:00
Simon Willison
5805024316
Implemented table.lookup(...), closes #44
* Add pk column if missing from insert
* Implemented table.lookup(...)
2019-07-23 06:06:59 -07:00
Simon Willison
034d498b31 Support Database(memory=True) for in-memory databases 2019-07-22 17:12:54 -07:00
Simon Willison
58db40d67c Better __repr__ for tables 2019-07-22 17:05:51 -07:00
Simon Willison
127a836054 Documented new table configuration options via .table() 2019-07-22 16:59:17 -07:00
Simon Willison
c65b67ca46
.get() method plus support for compound primary keys (#40)
* create_table now handles compound primary keys
* CLI now accepts multiple --pk for compound primary keys
* Docs for compound primary keys with CLI and Python library
* New .get() method plus documentation

Closes #36, closes #39
2019-07-14 21:28:51 -07:00
Simon Willison
f70e35c9bb Added table.rows_where(where, args) method 2019-07-14 11:58:40 -07:00
Simon Willison
ba6bd47f15 Typo fix 2019-07-14 09:25:57 -07:00
Simon Willison
fef96163d9
Minor markup cleanup 2019-07-09 04:55:04 -07:00
Simon Willison
5be66529a3
Fixed RST and Typo 2019-07-09 04:49:32 -07:00
Simon Willison
b0a2f897f4
Typo fix 2019-07-09 04:42:40 -07:00
Simon Willison
e8f887ef4a
sqlite-utils index-foreign-keys / db.index_foreign_keys()
Closes #33
2019-06-30 16:50:54 -07:00
Simon Willison
997d8758fc
db.add_foreign_keys() method
Closes #31
2019-06-28 23:27:38 -07:00
Simon Willison
362359da7e not_null= and defaults= arguments to various Python methods, refs #24 2019-06-12 23:10:07 -07:00
Simon Willison
07a10bdb2c foreign_keys=[...] can now detect tables and keys - closes #25 2019-06-12 22:32:26 -07:00
Simon Willison
d645032cfa add_foreign_key can now detect table and pk, refs #25 2019-06-12 21:51:09 -07:00
Simon Willison
2fed87da6e --not-null-default and not_null_default=, refs #24 2019-06-12 18:35:02 -07:00
Simon Willison
26b2cf3418 Changelog for 1.1 + docs for --ignore/ignore=True 2019-05-28 22:06:22 -07:00
Simon Willison
50e2f94b58 Ability to add a column that is a foreign key reference
Python API:

    db["dogs"].add_column("species_id", fk="species")
    # or
    db["dogs"].add_column("species_id", fk="species", fk_col="ref")

CLI:

    $ sqlite-utils add-column mydb.db dogs species_id --fk species
    # or
    $ sqlite-utils add-column mydb.db dogs species_id --fk species --fk-col ref

Closes #16
2019-05-28 21:54:43 -07:00
Simon Willison
1e28eeee8c
Fixed RST syntax bug 2019-05-27 22:25:03 -07:00