Commit graph

97 commits

Author SHA1 Message Date
Simon Willison
104f37fa4d
db[table].create(..., transform=True) and create-table --transform
Closes #467
2022-08-27 16:17:55 -07:00
Simon Willison
0e60f3c80c Better error message if table has no columns, closes #424 2022-04-13 15:39:48 -07:00
Simon Willison
931b1e1513 .insert(hash_id_columns=) parameter, closes #343 2022-03-01 16:00:51 -08:00
Simon Willison
aa24903113 Create table if_not_exists=True argument, closes #397 2022-02-05 17:28:53 -08:00
Simon Willison
79b5b58354 Basic test for db[t].create(...), refs #397 2022-02-05 17:19:39 -08:00
Simon Willison
ab392157f7 analyze=True for insert_all/upsert_all, refs #378 2022-01-10 17:00:34 -08:00
Simon Willison
0142c2a3c2 Improved test_create_index_analyze test, refs #378 2022-01-10 12:02:08 -08:00
Simon Willison
0d10402f7b table.create_index(..., analyze=True), refs #378 2022-01-10 12:00:24 -08:00
Simon Willison
ffb54427d3 insert now replaces square braces in column name with underscore, closes #341 2021-11-14 18:56:35 -08:00
Simon Willison
9cda5b070f Handle dict/tuple/list mapping to TEXT, closes #338 2021-11-14 16:36:00 -08:00
Simon Willison
13195d8747 Test demonstrating fix for #335 2021-11-14 14:55:42 -08:00
Simon Willison
e8d958109e create_index(..., find_unique_name=True) option, refs #335 2021-11-14 14:49:42 -08:00
Simon Willison
c62363ebdc Run mypy against tests/ too, refs #37 2021-08-18 14:49:12 -07:00
Simon Willison
90e211e3e2 Now complies with flake8, refs #291 2021-06-22 18:22:08 -07:00
Simon Willison
9faeef230b New db.query() method, refs #290 2021-06-21 21:03:59 -07:00
Simon Willison
b9629099ab Fix bug with upsert_all() and single column tables, closes #271 2021-06-12 19:57:21 -07:00
Simon Willison
51d01da30d
Ability to add descending order indexes (#262)
* DescIndex(column) for descending index columns, refs #260
* Ability to add desc indexes using CLI, closes #260
2021-05-28 22:01:38 -07:00
Simon Willison
a95954c481 Tests for unicode characters in nested JSON, refs #257 2021-05-18 19:56:53 -07:00
Simon Willison
c236894caa table.drop(ignore=True) option, refs #237 2021-02-25 09:05:08 -08:00
Simon Willison
a76e3b33ac Fixed bug with add_foreign_key against columns with spaces, closes #238 2021-02-25 08:53:53 -08:00
Simon Willison
8f042ae1fd Fix for bug with extra columns in later chunks, closes #234
Thanks @nieuwenhoven for the fix, proposed in #225
2021-02-14 13:03:31 -08:00
Simon Willison
b6840646ba .add_missing_columns() is now case insensitive, closes #221 2021-01-12 15:17:27 -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
7c0ef116ed pk=['id'] now equivalent to pk='id', closes #181 2020-10-14 14:59:38 -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 Wiles
367082e787
Typos in tests (#156)
Thanks @simonwiles
2020-09-09 11:21:22 -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
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
10c6fbc368 Applied Black 20.8b1, refs #142 2020-08-28 15:30:57 -07:00
Simon Wiles
947bb7626f
insert_all(..., alter=True) works for columns introduced after first 100 records
* Insert all columns for every chunk
* Update unit test to reflect new behaviour
* Test that exception is raised
* Update documentation

Closes #139. Thanks, Simon Wiles!
2020-08-28 15:30:13 -07:00
Simon Willison
f804690274 Support inserting UUID and memoryview, closes #128 2020-07-29 18:10:33 -07:00
Simon Willison
af3f81b540 Store decimal.Decimal in DB as FLOAT, closes #110 2020-05-10 18:50:03 -07:00
Simon Willison
5c1df4e306 replace=True and ignore=True parameters for create_view(), closes #106 2020-05-02 09:02:04 -07:00
Simon Willison
d56029549a Serialize JSON with non-JSON values, closes #102 2020-05-01 13:45:39 -07:00
Simon Willison
2ab62bcd54 New columns= parameter for over-riding column types, closes #100 2020-04-17 16:53:25 -07:00
Simon Willison
635c91475a Only set last_pk on singular .insert()/.update(), refs #98 2020-04-12 20:22:49 -07:00
Simon Willison
b436bdb594 Fixed bug with null columns, closes #95 2020-03-23 13:31:06 -07:00
Simon Willison
04ec53c039 Validate column names in more places, refs #86 2020-02-26 20:55:17 -08:00
Simon Willison
b0ca657f49 Disallow square braces in column names, closes #86 2020-02-26 20:16:02 -08:00
Simon Willison
685e6a1bb3 Detect subclasses of dict/tuple/list, fixes #87 2020-02-15 18:20:39 -08:00
Simon Willison
6f3cb2c106 create_index now works with columns with spaces, closes #85 2020-02-10 21:13:15 -08:00
Simon Willison
cfbc09967e Ran black, plus added comments for next step
Refs #66
2019-12-30 05:29:23 +00:00
Simon Willison
607a2a9ff6 insert --replace and insert(..., replace=True)
Refs #66
2019-12-30 05:29:23 +00:00
Simon Willison
8dab9fd1cc
insert_all() / .upsert_all() work with empty list (#64)
Closes #52
2019-11-06 20:32:37 -08: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
4ab8d46b03 Added table.update(pk, ..., alter=True) 2019-07-28 17:51:49 +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
5805024316
Implemented table.lookup(...), closes #44
* Add pk column if missing from insert
* Implemented table.lookup(...)
2019-07-23 06:06:59 -07:00