etlplus.database

etlplus.database package.

Database utilities for: - DDL rendering and schema management. - Schema parsing from configuration files. - Dynamic ORM generation. - Database engine/session management.

Functions

build_models(specs, *[, base])

Build SQLAlchemy ORM models from table specifications.

is_database_dsn(value)

Return whether value is a known database DSN string.

is_database_url(value)

Return whether value is a known database URL string.

load_and_build_models(path, *[, base])

Load table specifications from a file and build SQLAlchemy models.

load_database_url_from_config(path, *[, name])

Extract a database URL/DSN from a YAML/JSON config file.

load_table_spec(path)

Load a table specification from disk.

load_table_specs(path)

Load table specifications from a YAML file.

make_engine([url])

Create a SQLAlchemy Engine, defaulting to env config if no URL given.

render_table_sql(spec, *[, template, ...])

Render a single table spec into SQL text.

render_tables(specs, *[, template, ...])

Render multiple table specs into a list of SQL payloads.

render_tables_to_string(spec_paths, *[, ...])

Render one or more specs and concatenate the SQL payloads.

resolve_type(type_str)

Resolve a string type declaration to a SQLAlchemy TypeEngine.

Classes

Base(*args, **kwargs)

Base class for all ORM models.

ColumnSpec(*args, **kwargs)

Column specification suitable for ODBC / SQLite DDL.

DatabaseDialect(*values)

Supported database dialect identifiers.

ForeignKeySpec(*args, **kwargs)

Foreign key specification.

IdentitySpec(*args, **kwargs)

Identity specification.

IndexSpec(*args, **kwargs)

Index specification.

PrimaryKeySpec(*args, **kwargs)

Primary key specification.

ReferentialAction(*values)

Supported SQL referential actions for foreign key constraints.

SqlTypeAffinity(*values)

Portable SQL type affinities used for inferred database schemas.

TableSpec(*args, **kwargs)

Table specification.

UniqueConstraintSpec(*args, **kwargs)

Unique constraint specification.