output
sqllocks_spindle.output
¶
Output writers for various formats.
Classes¶
CsvWriter
¶
Write generated tables to CSV files.
Example
from sqllocks_spindle.output import CsvWriter
writer = CsvWriter(output_dir="./output") writer.write_all(result.tables)
PandasWriter
¶
Write generated tables to various local formats.
Methods:¶
to_csv(tables, output_dir, separator=',')
¶
Write all tables as CSV files.
to_tsv(tables, output_dir)
¶
Write all tables as tab-delimited text files.
to_jsonl(tables, output_dir)
¶
Write all tables as JSON Lines files (one JSON object per line).
to_parquet(tables, output_dir)
¶
Write all tables as Parquet files (requires pyarrow).
to_excel(tables, output_dir, single_workbook=True)
¶
Write tables as Excel files (requires openpyxl).
If single_workbook=True, writes one .xlsx with a sheet per table. If False, writes one .xlsx per table.
to_sql_inserts(tables, output_dir, schema_name=None, batch_size=1000, include_ddl=True, include_drop=True, include_go=True, sql_dialect='tsql', schema_meta=None, primary_keys=None, domain_name=None, scale=None, seed=None)
¶
Write tables as SQL scripts with optional CREATE TABLE DDL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
dict[str, DataFrame]
|
Dict of table_name -> DataFrame. |
required |
output_dir
|
str | Path
|
Directory for .sql files. |
required |
schema_name
|
str | None
|
SQL schema prefix (e.g. "dbo"). |
None
|
batch_size
|
int
|
Rows per INSERT batch. |
1000
|
include_ddl
|
bool
|
Prepend CREATE TABLE before INSERTs. |
True
|
include_drop
|
bool
|
Include DROP IF EXISTS before CREATE. |
True
|
include_go
|
bool
|
Include GO batch separators (T-SQL only). |
True
|
sql_dialect
|
str
|
"tsql", "postgres", or "mysql". |
'tsql'
|
schema_meta
|
dict[str, dict[str, dict]] | None
|
Per-table column metadata from SpindleSchema. Format: {table_name: {col_name: {type, nullable, max_length, ...}}} |
None
|
primary_keys
|
dict[str, list[str]] | None
|
Per-table primary key columns. {table_name: [col1, ...]} |
None
|
domain_name
|
str | None
|
Domain name for header comment. |
None
|
scale
|
str | None
|
Scale preset for header comment. |
None
|
seed
|
int | None
|
Seed for header comment. |
None
|