sqlite-utils/docs
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
..
.gitignore Initial project layout + database table creation tools 2018-07-28 06:46:17 -07:00
changelog.rst Release notes for 2.10.1 2020-06-23 14:13:18 -07:00
cli.rst Add insert --truncate option 2020-07-08 10:26:20 -07:00
conf.py Show version in docs 2019-07-14 12:45:00 -07:00
index.rst Don't show documentation badge on docs index 2020-05-03 08:47:28 -07:00
Makefile cd docs && make livehtml 2019-06-12 21:50:18 -07:00
python-api.rst Add insert --truncate option 2020-07-08 10:26:20 -07:00