home / github / issue_comments

Menu
  • GraphQL API

issue_comments: 1079376283

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/sqlite-utils/issues/420#issuecomment-1079376283 https://api.github.com/repos/simonw/sqlite-utils/issues/420 1079376283 IC_kwDOCGYnMM5AVfmb 9599 2022-03-25T19:39:30Z 2022-03-25T19:43:35Z OWNER Actually this doesn't work as I thought. This demo shows that the initialization code is run once per item, not a single time at the start of the run: ``` % sqlite-utils insert dogs.db dogs dogs.json --convert ' import random print("seeding") random.seed(10) print(random.random()) def convert(row): print(row) row["random_score"] = random.random() ' seeding 0.5714025946899135 seeding 0.5714025946899135 seeding 0.5714025946899135 seeding 0.5714025946899135 ``` Also that `print(row)` line is not being printed anywhere that gets to the console for some reason. ... my mistake, that happened because I changed this line in order to try to get local imports to work: ```python try: exec(code, globals, locals) return globals["convert"] except (AttributeError, SyntaxError, NameError, KeyError, TypeError): ``` It should be `locals["convert"]` {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} 1178546862  
Powered by Datasette ยท Queries took 1.131ms