home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 862475685

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/272#issuecomment-862475685 https://api.github.com/repos/simonw/sqlite-utils/issues/272 862475685 MDEyOklzc3VlQ29tbWVudDg2MjQ3NTY4NQ== 9599 2021-06-16T15:26:19Z 2021-06-16T15:29:38Z OWNER

Here's a radical idea: what if I combined sqlite-utils memory into sqlite-utils query?

The trick here would be to detect if the arguments passed on the command-line refer to SQLite databases or if they refer to CSV/JSON data that should be imported into temporary tables.

Detecting a SQLite database file is actually really easy - they all start with the same binary string: ```pycon

open("my.db", "rb").read(100) b'SQLite format 3\x00... `` (Need to carefully check that a CSV file withSQLite format 3` as the first column name doesn't accidentally get interpreted as a SQLite DB though).

So then what would the semantics of sqlite-utils query (which is also the default command) be?

  • sqlite-utils mydb.db "select * from x"
  • sqlite-utils my.csv "select * from my"
  • sqlite-utils mydb.db my.csv "select * from mydb.x join my on ..." - this is where it gets weird. We can't import the CSV data directly into mpdb.db - it's suppose to go into the in-memory database - so now we need to start using database aliases like mydb.x because we passed at least one other file?

The complexity here is definitely in the handling of a combination of SQLite database files and CSV filenames. Also, sqlite-utils query doesn't accept multiple filenames at the moment, so that will change.

I'm not 100% sold on this as being better than having a separate sqlite-utils memory command, as seen in #273.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
921878733  
Powered by Datasette · Queries took 0.99ms · About: github-to-sqlite