home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 729818242

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association pull_request body repo type active_lock_reason performed_via_github_app reactions draft state_reason
729818242 MDExOlB1bGxSZXF1ZXN0NTEwMjM1OTA5 189 Allow iterables other than Lists in m2m records 35681 closed 0     3 2020-10-26T18:47:44Z 2020-10-27T16:28:37Z 2020-10-27T16:24:21Z CONTRIBUTOR simonw/sqlite-utils/pulls/189

I was playing around with sqlite-utils, creating a Roam Research dogsheep-style importer for Datasette, and ran into a slight snag.

I wanted to use a generator to add an order column in an importer. It looked something like:

``` def order_generator(iterable, attr=None): if attr is None: attr = "order" order: int = 0

for i in iterable:
    i[attr] = order
    order += 1
    yield i

```

When I used this with insert_all and other things, it worked fine--but it didn't work as the records argument to m2m. I dug into it, and sqlite-utils is explicitly checking if the records argument is a list or a tuple. I flipped the check upside down, and now it checks if the argument is a mapping. If it's a mapping, it wraps it in a list, otherwise it leaves it alone.

(I get that it might not really make sense to put the order column on the second table. I changed my import schema a bit, and no longer have a real example, but maybe this change still makes sense.)

The automated tests still pass, but I did not add any new ones.

Let me know what you think! I'm really loving Datasette and its ecosystem; thanks for everything!

140912432 pull    
{
    "url": "https://api.github.com/repos/simonw/sqlite-utils/issues/189/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
0  

Links from other tables

  • 1 row from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 1.225ms · About: github-to-sqlite