diff options
| author | Arun Isaac | 2026-08-19 01:43:58 +0100 |
|---|---|---|
| committer | Arun Isaac | 2026-08-21 04:03:20 +0100 |
| commit | 6b0d271dc24f944ad4867804fbef0c73efcfa915 (patch) | |
| tree | 5aaa030678d479fbf5331bced665dfb7992d4d78 | |
| parent | d2282f6b7453a023af92424309e8713f5c8f7ca7 (diff) | |
| download | domagi-6b0d271dc24f944ad4867804fbef0c73efcfa915.tar.gz domagi-6b0d271dc24f944ad4867804fbef0c73efcfa915.tar.lz domagi-6b0d271dc24f944ad4867804fbef0c73efcfa915.zip | |
Initialize schema in crush subcommand.
We need to initialize the schema in the output database so that we get things like views.
| -rw-r--r-- | domagi/domagi.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/domagi/domagi.py b/domagi/domagi.py index d3321b7..dca240d 100644 --- a/domagi/domagi.py +++ b/domagi/domagi.py @@ -138,20 +138,22 @@ def chop(con, outfile, chop_to, threads): @common_options def crush(con, outfile, threads): set_duckdb_threads(con, threads) + with connect_duckdb(outfile, threads) as out_con: + out_con.execute(read_sql("schema.sql")) con.execute(f""" ATTACH '{outfile}' AS output_db (READ_WRITE); - CREATE TABLE output_db.segment AS + INSERT INTO output_db.segment SELECT segment.id, name, regexp_replace(sequence, 'N+', 'N', 'g') AS sequence FROM segment; - CREATE TABLE output_db.link AS + INSERT INTO output_db.link SELECT * FROM link; - CREATE TABLE output_db.path AS + INSERT INTO output_db.path SELECT * FROM path; - CREATE TABLE output_db.path_segment AS + INSERT INTO output_db.path_segment SELECT * FROM path_segment ORDER BY path_id, start, "end" """) |
