sqlite-utils/tests
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
..
__init__.py Initial project layout + database table creation tools 2018-07-28 06:46:17 -07:00
conftest.py Support Database(memory=True) for in-memory databases 2019-07-22 17:12:54 -07:00
test_black.py Revert "No need to skip black under Python 3.7 any more" 2019-01-24 19:08:52 -08:00
test_cli.py Add insert --truncate option 2020-07-08 10:26:20 -07:00
test_column_affinity.py Unit tests covering column_affinity, refs #92 2020-03-14 13:05:07 -07:00
test_conversions.py New conversions= feature, closes #77 2020-01-30 16:24:30 -08:00
test_create.py Store decimal.Decimal in DB as FLOAT, closes #110 2020-05-10 18:50:03 -07:00
test_create_view.py replace=True and ignore=True parameters for create_view(), closes #106 2020-05-02 09:02:04 -07:00
test_delete.py Added table.delete_where(), closes #62 2019-11-04 08:18:06 -08:00
test_docs.py sqlite-utils create-table docs, plus doc unit test 2020-05-02 21:13:49 -07:00
test_extracts.py extracts= table parameter, closes #46 2019-07-23 10:00:42 -07:00
test_fts.py .enable_fts() now works with columns with spaces in them, closes #90 2020-03-01 22:10:43 -08:00
test_get.py Refactored tests into new test_rows.py, refs #76 2020-04-15 18:04:55 -07:00
test_introspect.py Refactored tests into new test_rows.py, refs #76 2020-04-15 18:04:55 -07:00
test_lookup.py Implemented table.lookup(...), closes #44 2019-07-23 06:06:59 -07:00
test_m2m.py table.exists() now a documented method, closes #83 2020-02-08 15:56:03 -08:00
test_recreate.py Tests for Database(..., recreate=True), refs #97 2020-04-12 20:47:36 -07:00
test_rows.py .rows_where(..., order_by=) argument, closes #76 2020-04-15 20:12:55 -07:00
test_suggest_column_types.py Fixed bug with null columns, closes #95 2020-03-23 13:31:06 -07:00
test_update.py Validate column names in more places, refs #86 2020-02-26 20:55:17 -08:00
test_upsert.py Only set last_pk on singular .insert()/.update(), refs #98 2020-04-12 20:22:49 -07:00
utils.py 'sqlite-utils add-column name type' command, closes #15 2019-02-24 12:04:33 -08:00