-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
sqlite2duckdb/sqlite2duckdb/sqlite_to_duckdb.py
Lines 32 to 46 in c318ead
| ## Get sqlite Names | |
| conn.sql("USE __other") | |
| tables = [i[0] for i in conn.sql("SHOW tables").fetchall()] | |
| print(f"{len(tables)} tables found(s)") | |
| conn.sql(f"USE {db_name}") | |
| # Create tables | |
| for table in tables: | |
| print(f"Create duckdb table {table}") | |
| conn.sql(f"CREATE TABLE {table} AS select * FROM __other.{table}") | |
| conn.sql(f"DETACH __other") | |
| conn.close() | |
| end_time = time.perf_counter() | |
| execution_time = (end_time - start_time) * 1000 |
This seems overly complicated. What about something like
# Attach the DuckDB database (named)
conn.execute(f"ATTACH '{duckdb_file}' AS duck_db;")
# Attach the SQLITE database (named)
conn.execute(f"ATTACH '{sqlite_db}' as sqlite_db;")
conn.execute("COPY FROM DATABASE sqlite_db TO duck_db;")
chapmanjacobd and dridk
Metadata
Metadata
Assignees
Labels
No labels