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
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
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
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
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
Simon Willison
7784b924a1
Added create_index(..., if_not_exists=True), refs #14
2019-02-24 10:46:44 -08:00
Simon Willison
e7ffbcdb36
Ability to create unique indexes, refs #14
2019-02-24 10:41:51 -08:00
Simon Willison
10e3aab4c6
Fixed typo with last_pk
2019-02-23 22:49:54 -08:00
Simon Willison
dbf239e3fc
hash_id= mechanism for setting ID using content hash, closes #13
2019-02-23 20:36:40 -08:00
Simon Willison
e615d22c55
Support for numpy types, closes #11 ( #12 )
2019-02-23 20:02:19 -08:00
Simon Willison
ca225b02c0
Prettier indentation for CREATE TABLE
2019-02-23 12:52:04 -08:00
Simon Willison
3095f2e671
Added db[table].rows iterator
2019-02-21 21:29:50 -08:00
Simon Willison
62e1edeaf6
[] escaping for FTS columns
2019-02-21 20:17:58 -08:00
Simon Willison
ac9311aaf5
Refactored insert and upsert to share the same options
2019-02-06 21:50:25 -08:00
Simon Willison
7aab60d876
Handle datetime.date and datetime.time
2019-02-06 21:15:08 -08:00
Simon Willison
50589f8523
CLI insert tool now uses generators, closes #7
...
Also cleaned up the logic so we commit rows in batches too.
2019-01-27 22:26:45 -08:00
Simon Willison
f0afa5646b
insert_all() now accepts generator, closes #7
2019-01-27 22:12:18 -08:00
Simon Willison
57fc8ce55e
Database() constructor works with pathlib.Path
2019-01-27 15:53:41 -08:00
Simon Willison
9e74289397
'sqlite-utils insert tablename file.json' command
2019-01-24 21:06:41 -08:00
Simon Willison
0a8194e730
sqlite-utils optimize command, .optimize() and .detect_fts() table methods
2019-01-24 20:35:51 -08:00
Simon Willison
66fd63b119
Ability to list just FTS4 or FTS5 table names
2019-01-24 19:57:04 -08:00
Simon Willison
231224ba1a
Added vacuum to CLI and Python API
2019-01-24 19:39:04 -08:00
Simon Willison
228d595f7d
Allow column names to be reserved words
2019-01-24 19:01:10 -08:00
Simon Willison
6ad9037c96
Added support for bytes and datetime.datetime
2019-01-24 18:59:21 -08:00
Simon Willison
02862be04c
Default to FTS5
2018-08-12 17:21:55 -07:00
Simon Willison
9eacd30b1d
New column_order= parameter for setting column order
2018-08-08 16:06:49 -07:00
Simon Willison
72644b6e3f
Support method chaining, added .last_id for accessing lastrowid
...
Also shipping as 0.5
2018-08-05 18:42:43 -07:00
Simon Willison
a86c3ee832
Added db.create_view(name, sql) method
2018-08-02 08:24:16 -07:00
Simon Willison
741e8f7fe5
Make .indexes compatible with older SQLite versions ( #1 )
...
Older SQLite versions return a different set of columns from the PRAGMA we are using.
2018-08-02 08:17:29 -07:00
Simon Willison
0aa28293ad
Fix compatibility with SQLite prior to 3.16.0
...
pragma_index_info() and pragma_index_list() were introduced in 3.16.0 but the
version of SQLite running in Travis CI is earlier than that, hence the test
failures:
https://travis-ci.com/simonw/sqlite-utils/jobs/137617744
2018-08-01 08:29:53 -07:00
Simon Willison
4427d2d96f
table.create_index(columns, index_name) method
2018-08-01 08:20:44 -07:00
Simon Willison
c611ed80d2
.indexes property for introspecting indexes
2018-07-31 18:31:29 -07:00
Simon Willison
515d362ad6
.table_names and .tables properties plus expanded docs
2018-07-31 17:35:36 -07:00
Simon Willison
f4907f6df5
enable_fts(), populate_fts() and search() methods
2018-07-31 09:19:20 -07:00
Simon Willison
e888bb122d
Added .schema property, improved docs, release 0.3
2018-07-31 08:33:52 -07:00
Simon Willison
b69f8b6c85
table.count property, plus made a start on table documentation
2018-07-30 20:24:35 -07:00