Skip to content

Instantly share code, notes, and snippets.

@blackrez
Last active June 28, 2022 06:17
Show Gist options
  • Save blackrez/900c772bdb620be7b655d52ca0fec138 to your computer and use it in GitHub Desktop.
Save blackrez/900c772bdb620be7b655d52ca0fec138 to your computer and use it in GitHub Desktop.
import duckdb
import connectorx as cx
con = duckdb.connect(database=':memory:')
sqlite_db = "sqlite://station.db"
query_sqlite = "SELECT * FROM stations"
arr = cx.read_sql(sqlite_db, query_sqlite, return_type='arrow')
r = con.execute('SELECT ville, count(1) FROM arr GROUP BY ville')
r.fetchall()
# [('Marseille', 63), ('Paris', 54), ('Toulouse', 34), ('Nice', 29), ('Limoges', 22), ('Montpellier', 20), ('Le Mans', 18), ('Reims', 18), ('Lyon', 17), ('Nantes', 17)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment