Amjith Ramanujam
405e092d59
Option to add triggers when enabling FTS ( #57 )
...
--create-triggers CLI option and create_triggers=True in the Python library
* Add an option to create triggers for fts table.
* Add cli option for the create-update-trigger.
* Add tests for the create-update-trigger option.
* Change FTS table escaping to square brackets.
2019-09-02 16:42:28 -07: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
5516175ca6
Allow table objects to be passed to .m2m()
2019-08-04 05:09:17 +03:00
Simon Willison
d96a8f149e
Use existing m2m table if one exists
2019-08-03 21:16:51 +03:00
Simon Willison
b9256413d2
db.m2m_table_candidates(table, other_table)
2019-08-03 21:07:06 +03:00
Simon Willison
b6b92980c0
table.m2m(..., m2m_table=x) argument
2019-08-03 20:51:22 +03:00
Simon Willison
ba1211d445
Implemented .m2m(table, lookup=...)
2019-08-03 17:28:03 +03:00
Simon Willison
35eeafaaa3
table.m2m(...) method, with tests
2019-07-31 08:51:50 +03:00
Simon Willison
bc9c4db34b
.update(...) with no update argument sets last_pk
2019-07-28 17:59:52 +03:00
Simon Willison
4ab8d46b03
Added table.update(pk, ..., alter=True)
2019-07-28 17:51:49 +03:00
Simon Willison
e4a11b1815
Refactor .update() to use .get()
...
.pks introspection now returns [rowid] for rowid tables.
2019-07-28 15:44:33 +03:00
Simon Willison
455071f3c5
Unit tests for .update()
...
Also now set .last_pk to lastrowid for rowid tables.
2019-07-28 15:30:28 +03:00
Simon Willison
15368c5f59
First working version of .update(), refs #35
2019-07-28 15:15:50 +03:00
Simon Willison
535a5ea476
Documentation and tests for table.drop() method
2019-07-28 14:57:02 +03:00
Simon Willison
0c1b8b7f96
Use assertion to enforce <=999 columns
2019-07-28 14:41:57 +03:00
Simon Willison
62d2922528
Fix for too many SQL variables, closes #50
2019-07-28 14:10:56 +03:00
Simon Willison
941d281aee
extracts= table parameter, closes #46
2019-07-23 10:00:42 -07:00
Simon Willison
e22cfcd953
Removed a TODO which is now done
2019-07-23 15:05:04 +02: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
f3a4c3d3ee
db.create_table() now remembers configs
2019-07-23 09:47:19 +02: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
57e43baece
Table options can now be passed to constructor OR to insert_all()
...
If you want to set default options for a table, you can do this:
table = db.table("dogs", pk="id", column_order=["name", "age"])
If you pass those keyword arguments to the .insert/.update/etc
methods they will over-ride the defaults you set on the table.
table = db["dogs"] # This still works too
2019-07-22 16:30:54 -07:00
Simon Willison
152eb2afaf
Use pysqlite3 if available
2019-07-22 15:39:35 -07:00
Simon Willison
09316835e6
Implemented --tsv option, closes #41
2019-07-18 21:50:38 -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
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
f03d2eddd8
Handle datetime.time correctly
2019-06-25 21:18:35 -07:00
Simon Willison
976263effc
Sanity check add_foreign_key() column exists, closes #29
2019-06-20 16:58:18 -07:00
Simon Willison
208f56fbaf
--not-null and --default options to insert/update, closes #24
2019-06-12 23:30:16 -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
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
00c5a49a87
Option to ignore inserts if primary key exists already
...
Support for SQLite's INSERT OR IGNORE
In the API layer it looks like this:
fresh_db["test"].insert({"id": 1, "bar": 3}, ignore=True)
For the CLI layer it looks like this:
$ sqlite-utils insert data.db dogs dogs.json --ignore
Closes #21
2019-05-28 21:15:57 -07:00
Simon Willison
cec8c3c482
sqlite-utils rows now obeys --json-cols
2019-05-27 17:47:59 -07:00
Simon Willison
251e473041
--json-cols option for outputting nested JSON, closes #20
2019-05-24 17:56:44 -07:00
Simon Willison
747ea5d6bc
Fixed help text for sqlite-utils enable-fts
...
Closes #19
2019-05-24 17:43:46 -07:00
Simon Willison
eff52023c6
alter=True/--alter option to automatically add missing columns
...
Closes #18
2019-05-24 17:41:04 -07:00
Simon Willison
3cab079d3e
add-column col_type now optional, defaults to str
2019-02-24 14:24:00 -08:00
Simon Willison
557dc3f9a7
Improved foreign_keys= argument, closes #17
2019-02-24 14:12:45 -08:00
Simon Willison
f8d3b7cfe5
sqlite-utils add-foreign-key books.db books author_id authors id
...
Command for adding foreign keys to existing tables. Closes #2
2019-02-24 13:33:45 -08:00
Simon Willison
e1ca938aa1
table.add_foreign_key(column, other_table, other_column)
...
New mechanism for adding foreign key constraints to an existing SQLite
table.
SQLite ALTER TABLE does not support this out-of-the-box, so I instead
had to write some careful code that uses PRAGMA writable_schema = 1 to
directly modify the sqlite_master table.
Refs #2
2019-02-24 13:10:51 -08:00
Simon Willison
0bc49e938e
'sqlite-utils add-column name type' command, closes #15
2019-02-24 12:04:33 -08:00
Simon Willison
6d25f648ed
add_column now accepts explicit SQLite types, refs #15
2019-02-24 11:49:31 -08:00
Simon Willison
c5286d2c66
Black formatting
2019-02-24 11:40:58 -08:00
Simon Willison
dc2560879e
table.add_column(name, type) method, refs #15
2019-02-24 11:40:26 -08:00