From 6b0d271dc24f944ad4867804fbef0c73efcfa915 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 19 Aug 2026 01:43:58 +0100 Subject: Initialize schema in crush subcommand. We need to initialize the schema in the output database so that we get things like views. --- domagi/domagi.py | 10 ++++++---- 1 file 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" """) -- cgit 1.4.1