issue_comments
11 rows where author_association = "OWNER" and issue = 1363766973 sorted by updated_at descending
This data as json, CSV (advanced)
Suggested facets: created_at (date), updated_at (date)
issue 1
- Expose convert recipes to `sqlite-utils --functions` · 11 ✖
id | html_url | issue_url | node_id | user | created_at | updated_at ▲ | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
1239772256 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239772256 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5Wxg | simonw 9599 | 2022-09-07T19:07:51Z | 2022-09-07T19:09:52Z | OWNER | Or... I could automatically register multiple copies of the function of different arities! If I'm going to do something like that though I need to think carefully about how functions that have keyword-only arguments should work: https://peps.python.org/pep-3102/
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239766987 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239766987 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5VfL | simonw 9599 | 2022-09-07T19:01:49Z | 2022-09-07T19:01:49Z | OWNER | OK with this: ```diff diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index c51b101..93d82a9 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -30,6 +30,7 @@ from .utils import ( Format, TypeTracker, ) +from . import recipes CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) @@ -3029,7 +3030,7 @@ def load_extensions(db, load_extension): def _register_functions(db, functions): # Register any Python functions as SQL functions: sqlite3.enable_callback_tracebacks(True) - globals = {} + globals = {"r": recipes, "recipes": recipes} try: exec(functions, globals) except SyntaxError as ex: @@ -3037,4 +3038,4 @@ def _register_functions(db, functions): # Register all callables in the locals dict: for name, value in globals.items(): if callable(value) and not name.startswith(""): - db.register_function(value, name=name) + db.register_function(value, name=name, ignore_defaults=True) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 27c46b0..1407d23 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -370,6 +370,7 @@ class Database: self, fn: Callable = None, deterministic: bool = False, + ignore_defaults: bool = False, replace: bool = False, name: Optional[str] = None, ): @@ -397,7 +398,10 @@ class Database:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239763997 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239763997 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5Uwd | simonw 9599 | 2022-09-07T18:57:59Z | 2022-09-07T18:58:10Z | OWNER | Here's how to detect defaults in the function signature: ```pycon
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239762561 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239762561 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5UaB | simonw 9599 | 2022-09-07T18:56:13Z | 2022-09-07T18:56:13Z | OWNER | I could do this:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239762031 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239762031 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5URv | simonw 9599 | 2022-09-07T18:55:30Z | 2022-09-07T18:55:30Z | OWNER | That would be a breaking change though - existing code that registers functions with default parameters should continue to work unchanged (unless I want to ship |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239761280 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239761280 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5UGA | simonw 9599 | 2022-09-07T18:54:51Z | 2022-09-07T18:54:51Z | OWNER | I could teach this code here to only register the function using arguments that don't have default parameters: Or even this code here: |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239760001 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239760001 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5TyB | simonw 9599 | 2022-09-07T18:53:17Z | 2022-09-07T18:53:17Z | OWNER | So you would need to do this instead:
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239759022 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239759022 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5Tiu | simonw 9599 | 2022-09-07T18:52:08Z | 2022-09-07T18:52:08Z | OWNER | It's not quite that simple. I tried applying this patch: ```diff diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index c51b101..33e4d90 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -30,6 +30,7 @@ from .utils import ( Format, TypeTracker, ) +from . import recipes CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) @@ -3029,7 +3030,7 @@ def _load_extensions(db, load_extension): def _register_functions(db, functions): # Register any Python functions as SQL functions: sqlite3.enable_callback_tracebacks(True) - globals = {} + globals = {"r": recipes, "recipes": recipes} try: exec(functions, globals) except SyntaxError as ex: ``` Then got this:
But the code that register SQL functions introspects that signature, so creates a SQL function that requires four arguments. |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239699276 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239699276 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5E9M | simonw 9599 | 2022-09-07T17:49:49Z | 2022-09-07T17:49:49Z | OWNER | This feature is a tiny bit weird though: the recipe functions are not exposed to SQL by default, they are instead designed to be used with
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1239697643 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1239697643 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J5Ejr | simonw 9599 | 2022-09-07T17:48:00Z | 2022-09-07T17:48:00Z | OWNER | Will also need to update documentation here: https://sqlite-utils.datasette.io/en/stable/cli.html#defining-custom-sql-functions |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 | |
1238607591 | https://github.com/simonw/sqlite-utils/issues/484#issuecomment-1238607591 | https://api.github.com/repos/simonw/sqlite-utils/issues/484 | IC_kwDOCGYnMM5J06bn | simonw 9599 | 2022-09-06T20:16:39Z | 2022-09-06T20:16:39Z | OWNER | Here's the implementation for recipes at the moment: https://github.com/simonw/sqlite-utils/blob/5b969273f1244b1bcf3e4dc071cdf17dab35d5f8/sqlite_utils/utils.py#L434-L441 And here's the |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Expose convert recipes to `sqlite-utils --functions` 1363766973 |
Advanced export
JSON shape: default, array, newline-delimited, object
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]);
user 1