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)