octa --export-schema¶
Render a file's column schema as SQL DDL, a Pydantic model, a TypeScript interface, a JSON Schema document, or a Rust struct, and print it to stdout. Only the column list is read and no rows are serialised, so it's cheap even on large files.
Synopsis¶
| Flag | Required | Meaning |
|---|---|---|
-e FILE, --export-schema FILE |
yes | The file whose schema to export. |
-t TARGET, --target TARGET |
no | Output target (default postgres). See the table below. |
-f / --format does not apply, because the output is source code, not a
table. Like --convert, the schema-export action ignores it.
Targets¶
--target value |
Output |
|---|---|
postgres (default) |
CREATE TABLE in the Postgres dialect, double-quoted identifiers. |
mysql |
CREATE TABLE in the MySQL dialect, backtick identifiers, UNSIGNED types. |
sqlite |
CREATE TABLE in the SQLite dialect, affinity types (INTEGER/REAL/TEXT/BLOB). |
databricks |
CREATE TABLE in the Databricks (Spark SQL / Delta) dialect, backticks, STRING. |
snowflake |
CREATE TABLE in the Snowflake dialect, double quotes, VARCHAR / TIMESTAMP_NTZ. |
pydantic |
Pydantic v2 BaseModel with annotated fields and the right imports. |
typescript |
export interface with number / string / boolean mappings. |
json-schema |
JSON Schema (draft 2020-12) with properties and required. |
rust |
pub struct with serde derives and chrono types. |
The table / class / struct name is taken from the file stem (sample
for sample.csv), sanitised and PascalCased where the target requires.
Examples¶
Postgres DDL (the default)¶
$ octa --export-schema sales.parquet
-- Generated by octa - Postgres dialect
CREATE TABLE sales (
region TEXT,
quarter TEXT,
amount DOUBLE PRECISION,
order_id BIGINT
);
Snowflake DDL¶
$ octa -e sample.csv -t snowflake
-- Generated by octa - Snowflake dialect
CREATE TABLE sample (
id BIGINT,
name VARCHAR,
active BOOLEAN
);
Databricks DDL¶
$ octa --export-schema sample.csv --target databricks
-- Generated by octa - Databricks dialect
CREATE TABLE sample (
id BIGINT,
name STRING,
active BOOLEAN
);
Identifiers are emitted bare. A column name that can't work bare, one
with spaces, punctuation, or a leading digit, is quoted automatically
("…" for Postgres / SQLite / Snowflake, `…` for MySQL /
Databricks).
A Pydantic model, redirected to a file¶
A Rust struct¶
Multi-table sources¶
For a SQLite / DuckDB / GeoPackage file the CLI exports the schema of
the file's default table. To target a specific table inside a
multi-table database, use the
MCP export_schema tool, which accepts
a table argument.
Type mapping¶
Octa stores column types as Arrow-style strings (Int64, Utf8,
Float64, Timestamp(Microsecond, None), …). Each target maps them to
its closest native type; Arrow types with no clean equivalent fall
through to the target's TEXT-equivalent with a /* … */ comment so the
output is never silently wrong. The full mapping table lives on the
GUI Schema Export page, since the
CLI, GUI, and MCP all share the same renderers.
See also¶
- Schema Export: the same feature in the GUI.
- MCP
export_schematool: the same renderers over MCP, with multi-table support. octa --schema: prints the raw column list as a table (not DDL).octa --convert: converts the data itself, not the schema.