home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

13 rows where author_association = "OWNER", issue = 705975133 and user = 9599 sorted by updated_at descending

✖
✖
✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 1

  • simonw · 13 ✖

issue 1

  • table.transform() method · 13 ✖

author_association 1

  • OWNER · 13 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
696494070 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696494070 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ5NDA3MA== simonw 9599 2020-09-22T03:48:58Z 2020-09-22T03:48:58Z OWNER

One last thing. https://www.sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_change says that the first step should be:

If foreign key constraints are enabled, disable them using PRAGMA foreign_keys=OFF.

And the last steps should be:

If foreign key constraints were originally enabled then run PRAGMA foreign_key_check to verify that the schema change did not break any foreign key constraints.

Commit the transaction started in step 2.

If foreign keys constraints were originally enabled, reenable them now.

I need to implement that.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696490851 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696490851 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ5MDg1MQ== simonw 9599 2020-09-22T03:33:54Z 2020-09-22T03:33:54Z OWNER

It would be neat if .transform(pk=None) converted a primary key table to a rowid table.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696488201 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696488201 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ4ODIwMQ== simonw 9599 2020-09-22T03:21:16Z 2020-09-22T03:21:16Z OWNER

Just needs documentation now.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696485791 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696485791 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ4NTc5MQ== simonw 9599 2020-09-22T03:10:15Z 2020-09-22T03:10:15Z OWNER

Design decision needed on foreign keys: what does the syntax look like for removing an existing foreign key?

Since I already have a good implementation of add_foreign_key() I'm tempted to only support dropping them. Maybe like this:

python table.transform(drop_foreign_keys=[("author_id", "author", "id")]) It's a bit crufty but it's such a rare use-case that I think this will be good enough.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696480925 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696480925 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ4MDkyNQ== simonw 9599 2020-09-22T02:45:47Z 2020-09-22T02:45:47Z OWNER

I'm not going to do conversions= because it would be inconsistent with how they work elsewhere. The SQL generated by this function looks like this:

INSERT INTO dogs_new_tmp VALUES (a, b) SELECT a, b from dogs;

So passing conversions={"name": "upper(?)"}) wouldn't make sense, since we're not using arguments hence there is no-where for that ? to go.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696446658 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696446658 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ0NjY1OA== simonw 9599 2020-09-22T00:13:55Z 2020-09-22T00:14:21Z OWNER

Idea: allow a conversions= parameter, as seen on .insert_all() and friends, which lets you apply a SQL transformation function as part of the operation. E.g.:

python table.transform({"age": int}, conversions={"name": "upper(?)"})

https://sqlite-utils.readthedocs.io/en/stable/python-api.html#converting-column-values-using-sql-functions

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696445766 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696445766 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ0NTc2Ng== simonw 9599 2020-09-22T00:10:50Z 2020-09-22T00:11:12Z OWNER

A less horrible interface might be the following: ```python

Ensure the 'age' column is not null:

table.transform(not_null={"age"})

The 'age' column is not null but I don't want it to be:

table.transform(not_null={"age": False}) ``` So if the argument is a set it means "make sure these are all not null" - if the argument is a dictionary it means "set these to be null or not null depending on if their dictionary value is true or false".

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696444842 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696444842 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ0NDg0Mg== simonw 9599 2020-09-22T00:07:43Z 2020-09-22T00:09:05Z OWNER

Syntax challenge: I could use .transform(defaults={"age": None}) to indicate that the age column should have its default removed, but how would I tell .transform() that the age column, currently not null, should have the not null removed from it?

I could do this: .transform(not_not_null={"age"}) - it's a bit gross but it's also kind of funny. I actually like it!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696444353 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696444353 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ0NDM1Mw== simonw 9599 2020-09-22T00:06:12Z 2020-09-22T00:06:12Z OWNER

I should support not_null= and default= arguments to the .transform() method because it looks like you can't use ALTER TABLE to change those.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696443845 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696443845 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ0Mzg0NQ== simonw 9599 2020-09-22T00:04:31Z 2020-09-22T00:04:44Z OWNER

Good news: the .columns introspection does tell me those things: ```

import sqlite_utils db = sqlite_utils.Database(memory=True) db.create_table("foo", {"id": int, "name": str, "age": int}, defaults={"age": 1}, not_null={"name", "age"})

<Table foo (id, name, age)> >>> db["foo"] <Table foo (id, name, age)> >>> print(db["foo"].schema) CREATE TABLE [foo] ( [id] INTEGER, [name] TEXT NOT NULL, [age] INTEGER NOT NULL DEFAULT 1 ) >>> db["foo"].columns [Column(cid=0, name='id', type='INTEGER', notnull=0, default_value=None, is_pk=0), Column(cid=1, name='name', type='TEXT', notnull=1, default_value=None, is_pk=0), Column(cid=2, name='age', type='INTEGER', notnull=1, default_value='1', is_pk=0)] ```
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696443190 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696443190 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ0MzE5MA== simonw 9599 2020-09-22T00:02:22Z 2020-09-22T00:02:22Z OWNER

How would I detect which columns are not_null and what their defaults are? I don`t think my introspection logic handles that yet.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696443042 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696443042 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ0MzA0Mg== simonw 9599 2020-09-22T00:01:50Z 2020-09-22T00:01:50Z OWNER

When you transform a table, it should keep its primary key, foreign keys, not_null and defaults. I don't think it needs to care about hash_id or extracts= since those don't affect the structure of the table as it is being created - well, hash_id does but if we are transforming an existing table we will get the hash_id column for free.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  
696442621 https://github.com/simonw/sqlite-utils/pull/161#issuecomment-696442621 https://api.github.com/repos/simonw/sqlite-utils/issues/161 MDEyOklzc3VlQ29tbWVudDY5NjQ0MjYyMQ== simonw 9599 2020-09-22T00:00:23Z 2020-09-22T00:00:23Z OWNER

I still need to figure out what to do about these various other table properties: https://github.com/simonw/sqlite-utils/blob/b34c9b40c206d7a9d7ee57a8c1f198ff1f522735/sqlite_utils/db.py#L775-L787

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
table.transform() method 705975133  

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 513.685ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows