cldellow / datasette-parquet

Add DuckDB, Parquet, CSV and JSON lines support to Datasette
Apache License 2.0
47 stars 7 forks source link

canned queries seem to use sqlite? #2

Closed cldellow closed 1 year ago

cldellow commented 1 year ago

I was trying to use duckdb to export a parquet file with a writable query like:

{
  "databases": {
    "trove": {
      "queries": {
        "export": {
          "sql": "copy (select geo_id, name, ascii_name, latitude, longitude, feature_class, feature_code, country, cc2, admin1, admin2, admin3, admin4, population, elevation, dem, timezone, updated_at from cities500) to 'output.parquet' (format parquet)",
          "write": true
        }
      }
    }
  }
}

This gave: near "copy": syntax error and didn't seem to go through my rewriter. That error message is what sqlite3 gives if I run the command.

cldellow commented 1 year ago

Ah, because it is a writeable connection and I have not fiddled execute_write

cldellow commented 1 year ago

Hm, and now parts of database.py want the conn to be a context manager, so we're getting AttributeError on __enter__

cldellow commented 1 year ago

I put in a dummy context manager that does nothing - this is wrong for real world use, but sufficient for exporting parquet files, which is convenient. I might rip this out later.