home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

17 rows where "created_at" is on date 2022-09-07 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

issue 7

  • Expose convert recipes to `sqlite-utils --functions` 10
  • Handle really wide tables better 2
  • When running `auth` command, don't overwrite an existing auth.json file 1
  • sqlite-utils query --functions mechanism for registering extra functions 1
  • Conda Forge 1
  • Ability to set a custom facet_size per table 1
  • truncate_cells_html does not work for links? 1

user 3

  • simonw 15
  • ashanan 1
  • thewchan 1

author_association 2

  • OWNER 15
  • NONE 2
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/

python def compare(a, b, *ignore, key=None): ... I should think about how these work with db.register_function() anyway, since SQL functions cannot support keyword 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  
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:

     def register(fn):
         fn_name = name or fn.__name__
  • arity = len(inspect.signature(fn).parameters)
  • params = inspect.signature(fn).parameters
  • if ignore_defaults:
  • params = [p for p in params if params[p].default is inspect._empty]
  • arity = len(params) if not replace and (fn_name, arity) in self._registered_functions: return fn kwargs = {} I can now do this: % sqlite-utils memory --functions 'parsedate = r.parsedate' 'select parsedate("1st jan")' [{"parsedate(\"1st jan\")": "2022-01-01"}] ```
{
    "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

import inspect def foo(a, b, c=1, d=2): ... pass ... inspect.signature(foo) <Signature (a, b, c=1, d=2)> inspect.signature(foo).parameters mappingproxy(OrderedDict([('a', <Parameter "a">), ('b', <Parameter "b">), ('c', <Parameter "c=1">), ('d', <Parameter "d=2">)])) inspect.signature(foo).parameters['c'] <Parameter "c=1"> dir(inspect.signature(foo).parameters['c']) ['KEYWORD_ONLY', 'POSITIONAL_ONLY', 'POSITIONAL_OR_KEYWORD', 'VAR_KEYWORD', 'VAR_POSITIONAL', 'class', 'delattr', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'setstate', 'sizeof', 'slots', 'str', 'subclasshook', '_annotation', '_default', '_kind', '_name', 'annotation', 'default', 'empty', 'kind', 'name', 'replace'] inspect.signature(foo).parameters['c'].default 1 inspect.signature(foo).parameters['a'].default <class 'inspect._empty'> ```

{
    "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: python # 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, ignore_params_with_defaults=True) Introducing a new ignore_params_with_defaults option.

{
    "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 sqlite-utils 4.0).

{
    "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:

https://github.com/simonw/sqlite-utils/blob/d9b9e075f07a20f1137cd2e34ed5d3f1a3db4ad8/sqlite_utils/cli.py#L3037-L3040

Or even this code here:

https://github.com/simonw/sqlite-utils/blob/d9b9e075f07a20f1137cd2e34ed5d3f1a3db4ad8/sqlite_utils/db.py#L398-L418

{
    "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: sqlite-utils memory 'select parsedate("1st jan")' --functions ' def parsedate(s): return r.parsedate(s) '

{
    "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:

% sqlite-utils memory --functions 'parsedate = r.parsedate' 'select parsedate("1st jan")' Error: wrong number of arguments to function parsedate() % sqlite-utils memory --functions 'parsedate = r.parsedate' 'select parsedate("1st jan", 0, 0, 0)' [{"parsedate(\"1st jan\", 0, 0, 0)": "2022-01-01"}] The problem here is that the parsedate function signature looks like this:

https://github.com/simonw/sqlite-utils/blob/d9b9e075f07a20f1137cd2e34ed5d3f1a3db4ad8/sqlite_utils/recipes.py#L8

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 sqlite-utils convert. I guess with --functions support you could do something like this:

sqlite-utils data.db "update mytable set col1 = parsedate(col1)" --functions "parsedate = r.parsedate"
{
    "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  
1239516561 https://github.com/dogsheep/pocket-to-sqlite/issues/10#issuecomment-1239516561 https://api.github.com/repos/dogsheep/pocket-to-sqlite/issues/10 IC_kwDODLZ_YM5J4YWR ashanan 11887 2022-09-07T15:07:38Z 2022-09-07T15:07:38Z NONE

Thanks!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
When running `auth` command, don't overwrite an existing auth.json file 1246826792  
1238873948 https://github.com/simonw/sqlite-utils/issues/471#issuecomment-1238873948 https://api.github.com/repos/simonw/sqlite-utils/issues/471 IC_kwDOCGYnMM5J17dc simonw 9599 2022-09-07T03:46:26Z 2022-09-07T03:46:26Z OWNER

Is it still nfortunately slow and tricky when playing with floats ?

Not sure what you mean here?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
sqlite-utils query --functions mechanism for registering extra functions 1352932716  
1238868091 https://github.com/simonw/datasette/issues/1805#issuecomment-1238868091 https://api.github.com/repos/simonw/datasette/issues/1805 IC_kwDOBm6k_c5J16B7 simonw 9599 2022-09-07T03:33:15Z 2022-09-07T03:34:04Z OWNER

Here's an example (showing the default 2048 truncation length, so it's still pretty long):

https://latest.datasette.io/_memory?sql=select+%27https%3A%2F%2Fexample.com%2Faaaaaaaaaaa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ated

I think that would work better with word-wrap: anywhere:

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
truncate_cells_html does not work for links? 1363552780  
1238815924 https://github.com/simonw/sqlite-utils/issues/477#issuecomment-1238815924 https://api.github.com/repos/simonw/sqlite-utils/issues/477 IC_kwDOCGYnMM5J1tS0 thewchan 49702524 2022-09-07T01:46:24Z 2022-09-07T01:46:24Z NONE

Will do!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Conda Forge 1353441389  
1238790634 https://github.com/simonw/datasette/issues/596#issuecomment-1238790634 https://api.github.com/repos/simonw/datasette/issues/596 IC_kwDOBm6k_c5J1nHq simonw 9599 2022-09-07T00:55:52Z 2022-09-07T00:58:41Z OWNER

Or there's this recipe on StackOverflow that does the same thing without jQuery - there's an interactive demo on that page if you click "Run code snippet": https://stackoverflow.com/a/47038108/6083

All sorts of other potential solutions in that thread too.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Handle really wide tables better 507454958  
1238790158 https://github.com/simonw/datasette/issues/596#issuecomment-1238790158 https://api.github.com/repos/simonw/datasette/issues/596 IC_kwDOBm6k_c5J1nAO simonw 9599 2022-09-07T00:54:55Z 2022-09-07T00:54:55Z OWNER

The jqDoubleScroll plugin is interesting: https://github.com/avianey/jqDoubleScroll/blob/master/jquery.doubleScroll.js

Here's a demo: https://6317eba21040d42c0228aab9--tiny-tarsier-c1f294.netlify.app/example.html

Wouldn't be too hard to port that to work without jQuery.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Handle really wide tables better 507454958  
1238773577 https://github.com/simonw/datasette/issues/1804#issuecomment-1238773577 https://api.github.com/repos/simonw/datasette/issues/1804 IC_kwDOBm6k_c5J1i9J simonw 9599 2022-09-07T00:21:56Z 2022-09-07T00:21:56Z OWNER

facet_size is now documented here: https://docs.datasette.io/en/latest/facets.html#facets-in-metadata-json

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to set a custom facet_size per table 1363440999  

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 554.646ms · About: github-to-sqlite