home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

36 rows where "created_at" is on date 2023-07-22 sorted by updated_at descending

✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: issue_url, reactions, created_at (date), updated_at (date)

issue 11

  • table.create(..., replace=True) 7
  • Plugin system 6
  • Table renaming: db.rename_table() and sqlite-utils rename-table 5
  • feat: Implement a prepare_connection plugin hook 4
  • register_command plugin hook 3
  • `prepare_connection()` plugin hook 3
  • `datasette install -e` option 2
  • Don't test Python 3.7 against textual 2
  • Python API ability to opt-out of connection plugins 2
  • CLI docs should link to Python docs and vice versa 1
  • `.transform(keep_table=...)` option 1

user 3

  • simonw 34
  • eyeseast 1
  • codecov[bot] 1

author_association 3

  • OWNER 34
  • CONTRIBUTOR 1
  • NONE 1
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1646688748 https://github.com/simonw/sqlite-utils/issues/574#issuecomment-1646688748 https://api.github.com/repos/simonw/sqlite-utils/issues/574 IC_kwDOCGYnMM5iJnns simonw 9599 2023-07-22T23:12:03Z 2023-07-22T23:13:14Z OWNER

Just tried this out by adding the example from the docs to my sqlite-utils-hello-world plugin and running: bash sqlite-utils install -e ../sqlite-utils-hello-world Obtaining file:///Users/simon/Dropbox/Development/sqlite-utils-hello-world ... Then: bash sqlite-utils memory "select hello('simon')" json [{"hello('simon')": "Hello, simon!"}] Also: ```pycon

import sqlite_utils db = sqlite_utils.Database(memory=True) list(db.query("select hello('simon')")) [{"hello('simon')": 'Hello, simon!'}] db2 = sqlite_utils.Database(memory=True, execute_plugins=False) list(db2.query("select hello('simon')")) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py", line 494, in query cursor = self.execute(sql, params or tuple()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/simon/Dropbox/Development/sqlite-utils/sqlite_utils/db.py", line 512, in execute return self.conn.execute(sql, parameters) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ sqlean.dbapi2.OperationalError: no such function: hello ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`prepare_connection()` plugin hook 1816918185  
1646688339 https://github.com/simonw/sqlite-utils/issues/574#issuecomment-1646688339 https://api.github.com/repos/simonw/sqlite-utils/issues/574 IC_kwDOCGYnMM5iJnhT simonw 9599 2023-07-22T23:08:49Z 2023-07-22T23:08:49Z OWNER

Documentation: https://sqlite-utils.datasette.io/en/latest/plugins.html#prepare-connection-conn

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`prepare_connection()` plugin hook 1816918185  
1646688288 https://github.com/simonw/sqlite-utils/issues/575#issuecomment-1646688288 https://api.github.com/repos/simonw/sqlite-utils/issues/575 IC_kwDOCGYnMM5iJngg simonw 9599 2023-07-22T23:08:22Z 2023-07-22T23:08:22Z OWNER

Documented here: https://sqlite-utils.datasette.io/en/latest/plugins.html

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Python API ability to opt-out of connection plugins 1816919568  
1646687461 https://github.com/simonw/sqlite-utils/issues/575#issuecomment-1646687461 https://api.github.com/repos/simonw/sqlite-utils/issues/575 IC_kwDOCGYnMM5iJnTl simonw 9599 2023-07-22T23:01:44Z 2023-07-22T23:01:44Z OWNER

Relevant code: https://github.com/simonw/sqlite-utils/blob/3f80a026983d3e634f05a46f2a6da162b5139dd9/sqlite_utils/db.py#L346

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Python API ability to opt-out of connection plugins 1816919568  
1646687219 https://github.com/simonw/sqlite-utils/issues/567#issuecomment-1646687219 https://api.github.com/repos/simonw/sqlite-utils/issues/567 IC_kwDOCGYnMM5iJnPz simonw 9599 2023-07-22T22:59:36Z 2023-07-22T22:59:36Z OWNER

Now that we have two plugin hooks I'm closing this issue (we can open other issues for further hooks).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin system 1801394744  
1646687103 https://github.com/simonw/sqlite-utils/pull/573#issuecomment-1646687103 https://api.github.com/repos/simonw/sqlite-utils/issues/573 IC_kwDOCGYnMM5iJnN_ simonw 9599 2023-07-22T22:58:35Z 2023-07-22T22:58:35Z OWNER

https://sqlite-utils--573.org.readthedocs.build/en/573/plugins.html#prepare-connection-conn

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
feat: Implement a prepare_connection plugin hook 1816917522  
1646686382 https://github.com/simonw/sqlite-utils/pull/573#issuecomment-1646686382 https://api.github.com/repos/simonw/sqlite-utils/issues/573 IC_kwDOCGYnMM5iJnCu codecov[bot] 22429695 2023-07-22T22:52:22Z 2023-07-22T22:56:49Z NONE

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 :tada:

Comparison is base (86a352f) 96.09% compared to head (faf398f) 96.12%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #573 +/- ## ========================================== + Coverage 96.09% 96.12% +0.03% ========================================== Files 8 8 Lines 2794 2816 +22 ========================================== + Hits 2685 2707 +22 Misses 109 109 ``` | [Impacted Files](https://app.codecov.io/gh/simonw/sqlite-utils/pull/573?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) | Coverage Δ | | |---|---|---| | [sqlite\_utils/\_\_init\_\_.py](https://app.codecov.io/gh/simonw/sqlite-utils/pull/573?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-c3FsaXRlX3V0aWxzL19faW5pdF9fLnB5) | `100.00% <100.00%> (ø)` | | | [sqlite\_utils/db.py](https://app.codecov.io/gh/simonw/sqlite-utils/pull/573?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-c3FsaXRlX3V0aWxzL2RiLnB5) | `97.36% <100.00%> (+0.01%)` | :arrow_up: | | [sqlite\_utils/hookspecs.py](https://app.codecov.io/gh/simonw/sqlite-utils/pull/573?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-c3FsaXRlX3V0aWxzL2hvb2tzcGVjcy5weQ==) | `100.00% <100.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/simonw/sqlite-utils/pull/573/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
feat: Implement a prepare_connection plugin hook 1816917522  
1646686675 https://github.com/simonw/sqlite-utils/pull/573#issuecomment-1646686675 https://api.github.com/repos/simonw/sqlite-utils/issues/573 IC_kwDOCGYnMM5iJnHT simonw 9599 2023-07-22T22:54:38Z 2023-07-22T22:54:38Z OWNER

Glitch in the rendered documentation from https://sqlite-utils--573.org.readthedocs.build/en/573/plugins.html#prepare-connection-conn

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
feat: Implement a prepare_connection plugin hook 1816917522  
1646686477 https://github.com/simonw/sqlite-utils/issues/574#issuecomment-1646686477 https://api.github.com/repos/simonw/sqlite-utils/issues/574 IC_kwDOCGYnMM5iJnEN simonw 9599 2023-07-22T22:52:56Z 2023-07-22T22:52:56Z OWNER

Alex built this in: - #573

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`prepare_connection()` plugin hook 1816918185  
1646686424 https://github.com/simonw/sqlite-utils/issues/567#issuecomment-1646686424 https://api.github.com/repos/simonw/sqlite-utils/issues/567 IC_kwDOCGYnMM5iJnDY simonw 9599 2023-07-22T22:52:34Z 2023-07-22T22:52:34Z OWNER

Splitting off an issue for prepare_connection() since Alex got the PR in seconds before I shipped 3.34!

{
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 1,
    "rocket": 0,
    "eyes": 0
}
Plugin system 1801394744  
1646686332 https://github.com/simonw/sqlite-utils/pull/573#issuecomment-1646686332 https://api.github.com/repos/simonw/sqlite-utils/issues/573 IC_kwDOCGYnMM5iJnB8 simonw 9599 2023-07-22T22:52:01Z 2023-07-22T22:52:01Z OWNER

I was literally seconds away from shipping version 3.34 but I this looks good so I'm going to try and get it in there.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
feat: Implement a prepare_connection plugin hook 1816917522  
1646682686 https://github.com/simonw/sqlite-utils/issues/571#issuecomment-1646682686 https://api.github.com/repos/simonw/sqlite-utils/issues/571 IC_kwDOCGYnMM5iJmI- simonw 9599 2023-07-22T22:23:47Z 2023-07-22T22:23:47Z OWNER

Demo: ```pycon

from sqlite_utils import Database db = Database(memory=True) db["foo"].insert({"name": "Cleo"})

<Table foo (name)> >>> print(db["foo"].schema) CREATE TABLE [foo] ( [name] TEXT ) >>> db["foo"].transform(not_null={"name"}) <Table foo (name)> >>> print(db["foo"].schema) CREATE TABLE "foo" ( [name] TEXT NOT NULL ) >>> db["foo"].transform(types={"name": int}, keep_table="kept") <Table foo (name)> >>> print(db.schema) CREATE TABLE "kept" ( [name] TEXT NOT NULL ); CREATE TABLE "foo" ( [name] INTEGER NOT NULL ); ```
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`.transform(keep_table=...)` option 1816876211  
1646681386 https://github.com/simonw/sqlite-utils/issues/426#issuecomment-1646681386 https://api.github.com/repos/simonw/sqlite-utils/issues/426 IC_kwDOCGYnMM5iJl0q simonw 9599 2023-07-22T22:13:22Z 2023-07-22T22:13:22Z OWNER

I'm happy with how this works on https://sqlite-utils.datasette.io/en/stable/cli-reference.html

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
CLI docs should link to Python docs and vice versa 1205687423  
1646681192 https://github.com/simonw/sqlite-utils/issues/572#issuecomment-1646681192 https://api.github.com/repos/simonw/sqlite-utils/issues/572 IC_kwDOCGYnMM5iJlxo simonw 9599 2023-07-22T22:12:08Z 2023-07-22T22:12:08Z OWNER

Found it: https://github.com/simonw/sqlite-utils/blob/18f190e28334d821be78a1dbbf31d7610fc1f9c1/.github/workflows/test.yml#L29-L31

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Don't test Python 3.7 against textual 1816877910  
1646660777 https://github.com/simonw/sqlite-utils/issues/572#issuecomment-1646660777 https://api.github.com/repos/simonw/sqlite-utils/issues/572 IC_kwDOCGYnMM5iJgyp simonw 9599 2023-07-22T19:59:13Z 2023-07-22T19:59:13Z OWNER

I don't know where that is coming from! I can't see textual as a dependency we are pulling in anywhere.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Don't test Python 3.7 against textual 1816877910  
1646659809 https://github.com/simonw/sqlite-utils/issues/565#issuecomment-1646659809 https://api.github.com/repos/simonw/sqlite-utils/issues/565 IC_kwDOCGYnMM5iJgjh simonw 9599 2023-07-22T19:53:56Z 2023-07-22T19:53:56Z OWNER

CLI documentation:

  • https://sqlite-utils.datasette.io/en/latest/cli.html#renaming-a-table
  • https://sqlite-utils.datasette.io/en/latest/cli-reference.html#rename-table
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Table renaming: db.rename_table() and sqlite-utils rename-table 1786258502  
1646658978 https://github.com/simonw/sqlite-utils/issues/565#issuecomment-1646658978 https://api.github.com/repos/simonw/sqlite-utils/issues/565 IC_kwDOCGYnMM5iJgWi simonw 9599 2023-07-22T19:48:54Z 2023-07-22T19:48:54Z OWNER

Python method documentation: - https://sqlite-utils.datasette.io/en/latest/reference.html#sqlite_utils.db.Database.rename_table - https://sqlite-utils.datasette.io/en/latest/python-api.html#renaming-a-table

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Table renaming: db.rename_table() and sqlite-utils rename-table 1786258502  
1646657849 https://github.com/simonw/sqlite-utils/issues/565#issuecomment-1646657849 https://api.github.com/repos/simonw/sqlite-utils/issues/565 IC_kwDOCGYnMM5iJgE5 simonw 9599 2023-07-22T19:42:02Z 2023-07-22T19:42:02Z OWNER

Manually testing new rename-table command: $ sqlite-utils schema /tmp/f.db CREATE TABLE [foo] ( [id] INTEGER, [name] TEXT ); $ sqlite-utils rename-table /tmp/f.db bad-table hi Error: Table "bad-table" could not be renamed. no such table: bad-table $ sqlite-utils rename-table /tmp/f.db foo foo Error: Table "foo" could not be renamed. there is already another table or index with this name: foo $ sqlite-utils rename-table /tmp/f.db foo bar $ sqlite-utils schema /tmp/f.db CREATE TABLE "bar" ( [id] INTEGER, [name] TEXT );

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Table renaming: db.rename_table() and sqlite-utils rename-table 1786258502  
1646657324 https://github.com/simonw/sqlite-utils/issues/565#issuecomment-1646657324 https://api.github.com/repos/simonw/sqlite-utils/issues/565 IC_kwDOCGYnMM5iJf8s simonw 9599 2023-07-22T19:39:06Z 2023-07-22T19:39:06Z OWNER

Also need a design for an option for the .transform() method to indicate that the new table should be created with a new name without dropping the old one.

I think keep_table="name_of_table" is good for this.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Table renaming: db.rename_table() and sqlite-utils rename-table 1786258502  
1646656283 https://github.com/simonw/sqlite-utils/issues/567#issuecomment-1646656283 https://api.github.com/repos/simonw/sqlite-utils/issues/567 IC_kwDOCGYnMM5iJfsb eyeseast 25778 2023-07-22T19:32:24Z 2023-07-22T19:32:24Z CONTRIBUTOR

Cool. I might try to add a geojson plugin that handles both input and output. That would help me out a lot.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin system 1801394744  
1646656246 https://github.com/simonw/sqlite-utils/issues/565#issuecomment-1646656246 https://api.github.com/repos/simonw/sqlite-utils/issues/565 IC_kwDOCGYnMM5iJfr2 simonw 9599 2023-07-22T19:32:07Z 2023-07-22T19:32:07Z OWNER

Trying out a simple first implementation: ```pycon

from sqlite_utils import Database db = Database(memory=True, tracer=print) PRAGMA recursive_triggers=on; None db["foo"].insert({"id": 1}) 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 select name from sqlite_master where type = 'table' None select name from sqlite_master where type = 'view' None CREATE TABLE [foo] ( [id] INTEGER ); None select name from sqlite_master where type = 'view' None INSERT INTO [foo] ([id]) VALUES (?); [1] select name from sqlite_master where type = 'table' None select name from sqlite_master where type = 'table' None PRAGMA table_info([foo]) None

<Table foo (id)> >>> db.rename_table("foo", "baz") ALTER TABLE [foo] RENAME TO [baz] None >>> print(db.schema) select sql from sqlite_master where sql is not null None CREATE TABLE "baz" ( [id] INTEGER ); ```
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Table renaming: db.rename_table() and sqlite-utils rename-table 1786258502  
1646655272 https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646655272 https://api.github.com/repos/simonw/sqlite-utils/issues/568 IC_kwDOCGYnMM5iJfco simonw 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
}
table.create(..., replace=True) 1816851056  
1646654818 https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646654818 https://api.github.com/repos/simonw/sqlite-utils/issues/568 IC_kwDOCGYnMM5iJfVi simonw 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,
        ),
        ("select name from sqlite_master where type = 'view'", None),
    ]

E assert equals failed E [ [
E ('PRAGMA recursive_triggers=on;', None), ('PRAGMA recursive_triggers=on;', None),
E (
E "select name from sqlite_master where type =
E 'view'",
E None, ... E
E ...Full output truncated (13 lines hidden), use '-vv' to show

tests/test_tracer.py:12: AssertionError ============================================= short test summary info ============================================== FAILED tests/test_tracer.py::test_tracer - assert equals failed =========================================== 1 failed, 1 passed in 0.05s ============================================ ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.create(..., replace=True) 1816851056  
1646654383 https://github.com/simonw/sqlite-utils/issues/567#issuecomment-1646654383 https://api.github.com/repos/simonw/sqlite-utils/issues/567 IC_kwDOCGYnMM5iJfOv simonw 9599 2023-07-22T19:20:16Z 2023-07-22T19:20:16Z OWNER

Here's documentation for the new plugins mechanism, including a very short tutorial on writing a new plugin (inspired by https://llm.datasette.io/en/stable/plugins/tutorial-model-plugin.html):

https://sqlite-utils.datasette.io/en/latest/plugins.html

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin system 1801394744  
1646654275 https://github.com/simonw/sqlite-utils/issues/569#issuecomment-1646654275 https://api.github.com/repos/simonw/sqlite-utils/issues/569 IC_kwDOCGYnMM5iJfND simonw 9599 2023-07-22T19:19:35Z 2023-07-22T19:19:35Z OWNER

Documentation: https://sqlite-utils.datasette.io/en/latest/plugins.html#register-commands-cli

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
register_command plugin hook 1816852402  
1646653610 https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646653610 https://api.github.com/repos/simonw/sqlite-utils/issues/568 IC_kwDOCGYnMM5iJfCq simonw 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
}
table.create(..., replace=True) 1816851056  
1646653382 https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646653382 https://api.github.com/repos/simonw/sqlite-utils/issues/568 IC_kwDOCGYnMM5iJe_G simonw 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
}
table.create(..., replace=True) 1816851056  
1646652105 https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646652105 https://api.github.com/repos/simonw/sqlite-utils/issues/568 IC_kwDOCGYnMM5iJerJ simonw 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
}
table.create(..., replace=True) 1816851056  
1646648262 https://github.com/simonw/datasette/issues/2106#issuecomment-1646648262 https://api.github.com/repos/simonw/datasette/issues/2106 IC_kwDOBm6k_c5iJdvG simonw 9599 2023-07-22T18:42:20Z 2023-07-22T18:42:20Z OWNER

Tested this locally with: bash datasette install -e ../datasette-graphql Running datasette plugins confirmed that the plugin had been installed.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`datasette install -e` option 1816857442  
1646646931 https://github.com/simonw/datasette/issues/2106#issuecomment-1646646931 https://api.github.com/repos/simonw/datasette/issues/2106 IC_kwDOBm6k_c5iJdaT simonw 9599 2023-07-22T18:34:04Z 2023-07-22T18:34:04Z OWNER

Here's the diff for adding it to sqlite-utils: https://github.com/simonw/sqlite-utils/commit/ef31210bf06f920e0890e171c3198f0b0dc8d72d

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
`datasette install -e` option 1816857442  
1646645990 https://github.com/simonw/sqlite-utils/issues/569#issuecomment-1646645990 https://api.github.com/repos/simonw/sqlite-utils/issues/569 IC_kwDOCGYnMM5iJdLm simonw 9599 2023-07-22T18:29:40Z 2023-07-22T18:30:16Z OWNER

Example plugin: https://gist.github.com/simonw/ccfbbf9b384a38ac7535b01849f57daf

bash sqlite-utils install https://gist.github.com/simonw/ccfbbf9b384a38ac7535b01849f57daf/archive/cd7960e476c441a3c5f619e2a44a641a39b91467.zip pyproject.toml: ```toml [project] name = "sqlite-utils-hello-world" version = "0.1"

[project.entry-points.sqlite_utils] hello_world = "sqlite_utils_hello_world" `sqlite_utils_hello_world.py`:python import click import sqlite_utils

@sqlite_utils.hookimpl def register_commands(cli): @cli.command() def hello_world(): "Say hello world" click.echo("Hello world!") ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
register_command plugin hook 1816852402  
1646643676 https://github.com/simonw/sqlite-utils/issues/569#issuecomment-1646643676 https://api.github.com/repos/simonw/sqlite-utils/issues/569 IC_kwDOCGYnMM5iJcnc simonw 9599 2023-07-22T18:18:24Z 2023-07-22T18:18:24Z OWNER

Here's where I added that to LLM: https://github.com/simonw/llm/commit/a396950f7934e82a9968703bb3ce9ab7ab62f7f8

  • https://github.com/simonw/llm/issues/49
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
register_command plugin hook 1816852402  
1646643450 https://github.com/simonw/sqlite-utils/issues/567#issuecomment-1646643450 https://api.github.com/repos/simonw/sqlite-utils/issues/567 IC_kwDOCGYnMM5iJcj6 simonw 9599 2023-07-22T18:17:18Z 2023-07-22T18:17:18Z OWNER

I'm going to start by adding the register_command hook using the exact same pattern as Datasette and LLM.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin system 1801394744  
1646643379 https://github.com/simonw/sqlite-utils/issues/567#issuecomment-1646643379 https://api.github.com/repos/simonw/sqlite-utils/issues/567 IC_kwDOCGYnMM5iJciz simonw 9599 2023-07-22T18:16:54Z 2023-07-22T18:16:54Z OWNER

Would this possibly make a bunch of x-to-sqlite tools obsolete? Or nudge some to become plugins?

Yeah, it could do! That's not a terrible idea to be honest, those things have really been proliferating.

Alternatively, they could each register themselves as plugins in addition - so if you install e.g. pocket-to-sqlite you could then optionally also run it as sqlite-utils pocket-to-sqlite ...

The benefit there is for people who install sqlite-utils from Homebrew, where it gets its own virtual environment. They could run:

```bash brew install sqlite-utils sqlite-utils install pocket-to-sqlite

sqlite-utils pocket-to-sqlite ... ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Plugin system 1801394744  
1646642959 https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646642959 https://api.github.com/repos/simonw/sqlite-utils/issues/568 IC_kwDOCGYnMM5iJccP simonw 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
}
table.create(..., replace=True) 1816851056  
1646642666 https://github.com/simonw/sqlite-utils/issues/568#issuecomment-1646642666 https://api.github.com/repos/simonw/sqlite-utils/issues/568 IC_kwDOCGYnMM5iJcXq simonw 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
}
table.create(..., replace=True) 1816851056  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 675.54ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows