github
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646655272 | https://api.github.com/repos/simonw/sqlite-utils/issues/568 | 1646655272 | IC_kwDOCGYnMM5iJfco | 9599 | 2023-07-22T19:25:35Z | 2023-07-22T19:25:35Z | OWNER | Here's why that test broke: https://github.com/simonw/sqlite-utils/blob/58b577279fcd5ef6ce88f88b28668dffebfe7f44/sqlite_utils/db.py#L960-L964 I added an extra `if self[name].exists()` check to the `db.create_table()` method. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1816851056 | |
https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646654818 | https://api.github.com/repos/simonw/sqlite-utils/issues/568 | 1646654818 | IC_kwDOCGYnMM5iJfVi | 9599 | 2023-07-22T19:22:40Z | 2023-07-22T19:22:40Z | OWNER | I think this broke a test: ``` $ pytest tests/test_tracer.py =============================================== test session starts ================================================ platform darwin -- Python 3.11.4, pytest-7.2.2, pluggy-1.0.0 rootdir: /Users/simon/Dropbox/Development/sqlite-utils plugins: icdiff-0.6, hypothesis-6.68.2 collected 2 items tests/test_tracer.py F. [100%] ===================================================== FAILURES ===================================================== ___________________________________________________ test_tracer ____________________________________________________ def test_tracer(): collected = [] db = Database( memory=True, tracer=lambda sql, params: collected.append((sql, params)) ) db["dogs"].insert({"name": "Cleopaws"}) db["dogs"].enable_fts(["name"]) db["dogs"].search("Cleopaws") > assert collected == [ ("PRAGMA recursive_triggers=on;", None), ("select name from sqlite_master where type = 'view'", None), ("select name from sqlite_master where type = 'table'", None), ("select name from sqlite_master where type = 'view'", None), ("CREATE TABLE [dogs] (\n [name] TEXT\n);\n ", None), ("select name from sqlite_master where type = 'view'", None), ("INSERT INTO [dogs] ([name]) VALUES (?);", ["Cleopaws"]), ("select name from sqlite_master where type = 'view'", None), ( "CREATE VIRTUAL TABLE [dogs_fts] USING FTS5 (\n [name],\n content=[dogs]\n)", None, ), ( "INSERT INTO [dogs_fts] (rowid, [name])\n SELECT rowid, [name] FROM [dogs];", None, … | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1816851056 | |
https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646653610 | https://api.github.com/repos/simonw/sqlite-utils/issues/568 | 1646653610 | IC_kwDOCGYnMM5iJfCq | 9599 | 2023-07-22T19:14:56Z | 2023-07-22T19:14:56Z | OWNER | Manual testing of CLI command as well: ``` $ sqlite-utils create-table /tmp/f.db foo id integer $ sqlite-utils create-table /tmp/f.db foo id integer Error: Table "foo" already exists. Use --replace to delete and replace it. $ sqlite-utils create-table /tmp/f.db foo id integer --replace $ sqlite-utils create-table /tmp/f.db foo id $ sqlite-utils schema /tmp/f.db CREATE TABLE [foo] ( [id] INTEGER ); $ sqlite-utils create-table /tmp/f.db foo id integer name str --transform Error: column types must be one of ('INTEGER', 'TEXT', 'FLOAT', 'BLOB') $ sqlite-utils create-table /tmp/f.db foo id integer name text --transform $ sqlite-utils schema /tmp/f.db CREATE TABLE "foo" ( [id] INTEGER, [name] TEXT ); $ sqlite-utils create-table /tmp/f.db foo id integer name text --ignore $ sqlite-utils create-table /tmp/f.db foo id integer name text --replace $ sqlite-utils schema /tmp/f.db CREATE TABLE [foo] ( [id] INTEGER, [name] TEXT ); ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1816851056 | |
https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646653382 | https://api.github.com/repos/simonw/sqlite-utils/issues/568 | 1646653382 | IC_kwDOCGYnMM5iJe_G | 9599 | 2023-07-22T19:13:20Z | 2023-07-22T19:13:20Z | OWNER | Demo: ```pycon >>> from sqlite_utils import Database >>> db = Database(memory=True) >>> db["foo"].create({"id": int}) <Table foo (id)> >>> db["foo"].create({"id": int}) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py", line 1647, in create self.db.create_table( File "/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py", line 1030, in create_table self.execute(sql) File "/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py", line 510, in execute return self.conn.execute(sql) ^^^^^^^^^^^^^^^^^^^^^^ sqlean.dbapi2.OperationalError: table [foo] already exists >>> db["foo"].create({"id": int}, ignore=True) <Table foo (id)> >>> db["foo"].create({"id": int, "name": str}, replace=True) <Table foo (id, name)> >>> db["foo"].create({"id": int, "name": str, "age": int}, transform=True) <Table foo (id, name, age)> ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1816851056 | |
https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646652105 | https://api.github.com/repos/simonw/sqlite-utils/issues/568 | 1646652105 | IC_kwDOCGYnMM5iJerJ | 9599 | 2023-07-22T19:05:13Z | 2023-07-22T19:05:13Z | OWNER | I think this is `replace=True` and `ignore=True` to match the CLI. And refactoring the CLI to use them. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1816851056 | |
https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646642959 | https://api.github.com/repos/simonw/sqlite-utils/issues/568 | 1646642959 | IC_kwDOCGYnMM5iJccP | 9599 | 2023-07-22T18:14:49Z | 2023-07-22T18:14:49Z | OWNER | Here's where those are implemented for the `create-table` CLI command: https://github.com/simonw/sqlite-utils/blob/f7af23837deab5c98dae9441d1f68318065d7d8c/sqlite_utils/cli.py#L1543-L1564 | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1816851056 | |
https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646642666 | https://api.github.com/repos/simonw/sqlite-utils/issues/568 | 1646642666 | IC_kwDOCGYnMM5iJcXq | 9599 | 2023-07-22T18:13:19Z | 2023-07-22T18:13:19Z | OWNER | https://sqlite-utils.datasette.io/en/stable/cli-reference.html#create-table ```bash sqlite-utils create-table ... --replace ``` That also has `--ignore`: ``` --ignore If table already exists, do nothing --replace If table already exists, replace it --transform If table already exists, try to transform the schema ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1816851056 |