Commit graph

164 commits

Author SHA1 Message Date
Simon Willison
0d2a47eab9 .reset_counts() method and reset-counts command, closes #219 2021-01-03 12:59:31 -08:00
Simon Willison
b4f09146d3 table.has_counts_triggers property, refs #219 2021-01-03 12:41:24 -08:00
Simon Willison
94b5023066 table.count now uses cached counts if db.use_counts_table
Closes #215
2021-01-03 12:19:34 -08:00
Simon Willison
de08096989 database.triggers_dict, closes #216 2021-01-02 20:19:55 -08:00
Simon Willison
3d041d34d5 Renamed db.escape() to db.quote() and documented it
Closes #217
2021-01-02 20:15:04 -08:00
Simon Willison
9a5c92b63e db.enable_counts() method, closes #213 2021-01-02 14:03:52 -08:00
Simon Willison
1cad7fad3e table.enable_counts() method, closes #212 2021-01-02 13:40:10 -08:00
Simon Willison
b067f1ff57 table.triggers_dict property, closes #211 2021-01-01 18:10:04 -08:00
Simon Willison
69a121e088
sqlite-utils analyze-tables command and table.analyze_column() method
Closes #207
2020-12-12 23:20:11 -08:00
Andreas Madsack
c5f4f0f70c
Use jsonify_if_need for sql updates (#204)
* add failing tests for update with json values
* use jsonify_if_needed in for sql updates

Thanks, @mfa
2020-12-08 09:49:42 -08:00
Simon Willison
ce2b07c358 Updated docs for .search_sql() method
Also improved indentation of generated SQL queries. Refs #197
2020-11-08 09:04:37 -08:00
Simon Willison
c5a798c15f .search_sql() fully respects columns=, closes #201
Refs #192 and #197
2020-11-08 08:53:53 -08:00
Simon Willison
bce1872109 order= is now order_by=, refs #197 2020-11-06 16:43:33 -08:00
Simon Willison
771bd81b62 search_sql() returns most relevant first, not least
Refs #192
2020-11-06 15:50:02 -08:00
Simon Willison
63e2bdf18d Added test for sqlite-utils search, refs #192 2020-11-06 15:40:42 -08:00
Simon Willison
d411fba1f4 .search() works for FTS4, yields dicts
Closes #198, refs #197
2020-11-06 10:30:41 -08:00
Simon Willison
27b67f1cae @db.register_function(..., replace=True), closes #199 2020-11-06 10:30:41 -08:00
Simon Willison
7c22a64fb6 .search() now works differently for FTS4 v.s. FTS5 2020-11-06 10:30:41 -08:00
Simon Willison
de39e8db1e Refactored to table.search_sql() method, added --limit 2020-11-06 10:30:41 -08:00
Simon Willison
59d8689ed0 table.virtual_table_using property, closes #196 2020-11-04 19:53:45 -08:00
Simon Willison
0789bad8f7 @db.register_function(deterministic=True), closes #191 2020-10-28 14:30:58 -07:00
Simon Willison
c7e5dd6451 Applied latest Black 2020-10-27 09:26:01 -07:00
Adam Wolf
f045d8559a
Allow iterables other than lists in m2m records (#189)
* Allow iterables other than Lists in m2m records
* Add test for iterable m2m records

Thanks, @adamwolf!
2020-10-27 09:24:21 -07:00
Simon Willison
21ff60e3b1 --load-extension= for many more commands, closes #137
Also added --load-extension=spatialite shortcut, closes #136
2020-10-16 12:14:22 -07:00
Simon Willison
7c0ef116ed pk=['id'] now equivalent to pk='id', closes #181 2020-10-14 14:59:38 -07:00
Simon Willison
5a63b9e88c Simplify drop-foreign-key, and drop_foreign_keys, closes #177 2020-09-24 09:19:07 -07:00
Simon Willison
022cdd97a9
Much, much faster extract() implementation
Takes my test down from ten minutes to four seconds!

* Removed unnecessary update() optimization
* Added column_order= to .transform() and .transform_sql()
* Tests for reusing lookup table in extract()

Closes #172
2020-09-24 08:43:55 -07:00
Simon Willison
5eb14d1c1f Added several missing 'return self' to support chaining 2020-09-24 07:51:36 -07:00
Simon Willison
66d506587e Some optimizations for extract()
Refs #172 - seems to give me about 20% speedup.
2020-09-23 13:12:19 -07:00
Simon Willison
5534c320e4 Applied Black 2020-09-22 17:32:40 -07:00
Simon Willison
b8e0048485 Fixed PRAGMA foreign_keys handling for .transform, closes #167 2020-09-22 17:12:56 -07:00
Simon Willison
5c4d58d152 Progress bar for "sqlite-utils extract", closes #169 2020-09-22 17:02:29 -07:00
Simon Willison
2db6c5b2d5 table.extract() now works with rowid tables, refs #42 2020-09-22 16:11:28 -07:00
Simon Willison
71782311ce New .rows_where(select=) argument 2020-09-22 16:10:14 -07:00
Simon Willison
c3210f2ffb Added table.extract(rename=) option, refs #42 2020-09-22 15:57:02 -07:00
Simon Willison
f8553799d3 table.extract() method, refs #42 2020-09-22 15:20:18 -07:00
Simon Willison
f29f6821f2 Applied Black 2020-09-22 00:49:27 -07:00
Simon Willison
752d261229 Implemented sqlite-utils transform command, closes #164 2020-09-22 00:47:58 -07:00
Simon Willison
f8e10df00e
Keyword only arguments for transform()
Also renamed columns= to types=

Closes #165
2020-09-21 23:39:10 -07:00
Simon Willison
987dd123f2
table.transform() method - closes #114 2020-09-21 21:20:01 -07:00
Simon Willison
482477585a @db.register_function decorator, closes #162 2020-09-21 17:31:43 -07:00
Simon Willison
e23eedb4ce ignore=True argument for add_foreign_key, closes #112
Also --ignore for add-foreign-key command

Plus table.add_foreign_key(...) now returns self, allowing more chaining
2020-09-20 15:17:25 -07:00
Simon Willison
ecb50c8f76 .enable_fts(..., replace=True) argument, closes #160 2020-09-20 15:05:46 -07:00
Simon Wiles
e6d202b742
Handle case where subsequent records (after first batch) include extra columns
Refs #145.

* Extract build_insert_queries_and_params
* Extract insert_chunk so it can be called recursively

Thanks, @simonwiles
2020-09-08 16:20:36 -07:00
Simon Willison
176f4e0ef4 sqlite-utils rebuild-fts command, closes #155 2020-09-08 16:16:03 -07:00
Simon Willison
9680a0291c 'Soundness check' is better 2020-09-08 15:24:39 -07:00
Simon Willison
64799df78b .optimize() no longer cleans up _docsize
This isn't necessary any more since the new .rebuild_fts()
method can achieve the same thing.

Refs #155, #153
2020-09-08 15:18:12 -07:00
Simon Willison
4c0f79398f table.rebuild_fts() method, refs #155 2020-09-08 15:09:25 -07:00
Simon Willison
cf2cb244fa
Tracer mechanism for showing underlying SQL queries
* Pass a tracer= function to Database constructor
* New db.tracer() contextmanager
* Neater SQL indentation, because tracer means it could be visible now
* New db.execute() and db.executescript() methods

Closes #150
2020-09-07 14:56:59 -07:00
Simon Willison
3e87500e15 table.optimize() deletes junk docsize rows
Closes #153. Closes #149.
2020-09-07 14:16:13 -07:00