Created
February 26, 2026 10:22
-
-
Save tubackkhoa/ca1d9c1b6fb1a35933fb70cf241e45c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import duckdb | |
| sqlite_file = "data/apscheduler_events.db" | |
| duckdb_file = "data/apscheduler_events.duckdb" | |
| con = duckdb.connect(duckdb_file) | |
| con.execute("INSTALL sqlite;") | |
| con.execute("LOAD sqlite;") | |
| # get tables | |
| tables = con.execute( | |
| f""" | |
| SELECT name | |
| FROM sqlite_scan('{sqlite_file}', 'sqlite_master') | |
| WHERE type='table' | |
| """ | |
| ).fetchall() | |
| for (table,) in tables: | |
| print(f"Copying {table}") | |
| con.execute( | |
| f""" | |
| CREATE TABLE "{table}" AS | |
| SELECT * FROM sqlite_scan('{sqlite_file}', '{table}'); | |
| """ | |
| ) | |
| con.close() | |
| print("✅ Conversion complete") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment