From cab33cf787f56e8113243a1ef92ef8d5c0e6330c Mon Sep 17 00:00:00 2001 From: Dierk Date: Wed, 13 May 2026 12:03:46 +0200 Subject: [PATCH] Auto-create schema if it does not exist Co-Authored-By: Claude Sonnet 4.6 --- excel_import/importer.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/excel_import/importer.py b/excel_import/importer.py index 15bc500..e93c0fc 100644 --- a/excel_import/importer.py +++ b/excel_import/importer.py @@ -66,6 +66,9 @@ class Importer: def _ensure_table(self, conn, df: pd.DataFrame, cfg: SheetConfig): schema, table_name = _split_table(cfg.target_table) insp = inspect(conn) + if schema and schema not in insp.get_schema_names(): + conn.execute(text(f"CREATE SCHEMA {schema}")) + logger.info("Created schema %r", schema) if not insp.has_table(table_name, schema=schema): meta = MetaData() cols = build_columns(df, cfg.columns, self.config.default_varchar_length)