home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 507050894

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/23#issuecomment-507050894 https://api.github.com/repos/simonw/sqlite-utils/issues/23 507050894 MDEyOklzc3VlQ29tbWVudDUwNzA1MDg5NA== 9599 2019-06-30T16:51:39Z 2019-06-30T16:55:16Z OWNER

One option:

db.insert_m2m("dogs", 1, "breeds", 3)

This would create the missing m2m table if it did not already exist, and call it dogs_breeds.

You can pass an optional m2m_table= argument to specify the table name:

db.insert_m2m("dogs", 1, "breeds", 3, m2m_table="dog_m2m_breeds")

Maybe allow passing extra key/value pairs that will be inserted into the m2m table?

db.insert_m2m("dogs", 1, "breeds", 3, m2m_extra={"classified_on_date": "2019-04-01"})

Could even accept alter=True to cause the m2m table to be automatically altered to fit any m2m_extra= columns that do not already exist.

It would be nice if there was a table.* method for this which allowed you to send three arguments rather than four. Maybe something like this:

db["dogs"].insert_m2m(1, "breeds", 3)

It's a bit confusing them both having the same method name though. Also calling it insert_m2m here is odd because you're not inserting into the dogs table.

Maybe this instead?

db["dogs"].m2m(1, "breeds", 3)
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
449565204  
Powered by Datasette · Queries took 1.248ms · About: github-to-sqlite