sqlalchemy_boltons package

Submodules

sqlalchemy_boltons.core module

sqlalchemy_boltons.core.bytes_prefix_upper_bound(prefix)[source]
Return type:

bytes | None

sqlalchemy_boltons.core.bytes_startswith(operand, prefix)[source]

Produces SQL equivalent to operand.startswith(prefix), but which works correctly for BLOB-like columns.

As an example, the resulting SQL for bytes_startswith(x, b"abc") is something like (x >= b"abc") & (x < b"abd").

Return type:

ColumnElement[object]

sqlalchemy_boltons.core.count(select_from=None, count_argument=None)[source]

Produces COUNT(*) if select_from is None, otherwise SELECT COUNT(*) FROM select_from. This is a shorthand for sa.select(sa.func.count()).select_from(select_from).

sqlalchemy_boltons.core.count1(select_from=None)[source]

Produces COUNT(1).

sqlalchemy_boltons.orm module

class sqlalchemy_boltons.orm.IdKey(mapped, key, identity_token)[source]

Bases: Generic[T]

Holds the primary key information for an ORM instance. This is useful for passing a reference to an ORM object across different sessions and/or threads.

For example:

import sqlalchemy as sa
from sqlalchemy import orm as sao
from sqlalchemy_boltons.orm import IdKey

Base = sao.declarative_base()


class MyClass(Base):
    __tablename__ = "my_table"

    id = sa.Column(sa.Integer, primary_key=True)


session = Session()
instance = session.execute(sa.select(MyClass).where(...)).one()
key = IdKey.from_instance(instance)

# ...later...
session = Session()
instance = key.get_one(session)
classmethod from_instance(instance)[source]
Return type:

IdKey[TypeVar(T)]

get(_session, **kw)[source]

Shortcut for session.get(k.mapped, k.key, identity_token=k.identity_token).

Return type:

Optional[TypeVar(T)]

get_one(_session, **kw)[source]

Like get(), but raises sqlalchemy.exc.NoResultFound if no row is found.

Return type:

TypeVar(T)

identity_token: Any
key: tuple
mapped: type[TypeVar(T)]
class sqlalchemy_boltons.orm.RelationshipComparator(relationship)[source]

Bases: object

This wrapper makes it possible to compare a table against a relationship using join_expr(). This can be used for constructing a subquery that filters using a relationship to a table from the outer query.

For example:

import sqlalchemy as sa
from sqlalchemy import orm as sao
from sqlalchemy_boltons.orm import RelationshipComparator as Rel

Base = sao.declarative_base()


class Parent(Base):
    __tablename__ = "parent"

    id = sa.Column(sa.Integer, primary_key=True)

    children = sao.relationship("Child", back_populates="parent")


class Child(Base):
    __tablename__ = "child"

    id = sa.Column(sa.Integer, primary_key=True)
    parent_id = sa.Column(sa.ForeignKey("parent.id"), index=True)

    parent = sao.relationship("Parent", back_populates="children")


# We want a query that selects every Parent that has at least one child. We also want to use aliases.
P = sao.aliased(Parent)
C = sao.aliased(Child)

# This is the boring old way of doing it, which requires explicitly stating the filtering conditions in terms
# of the columns in both tables.
q1 = sa.select(P).where(sa.select(C).where(C.parent_id == P.id).exists())

# Reuse the filtering conditions from the ORM relationship!
q2 = sa.select(P).where(sa.select(C).where(Rel(C.parent) == P).exists())

assert str(q1) == str(q2), "these should produce the same SQL code!"

Based on this discussion: https://groups.google.com/g/sqlalchemy/c/R-qOlzzVi0o/m/NtFswgJioDIJ

class sqlalchemy_boltons.orm.Relationships(tables, names, primary, secondary=None, kwargs=<factory>)[source]

Bases: object

Generates pairs of relationships. It’s like the legacy “backref” parameter but it allows you to configure each side of the relationship separately.

For example:

_rel_children_parent = _orm.Relationships(
    lambda: dict(a=Parent, b=Child),
    dict(ab="children", ba="parent"),
    lambda fk, a, b: a.id == fk(b.parent_id),
)


class Parent(Base):
    __tablename__ = "parent"

    id = sa.Column(sa.Integer, primary_key=True)

    children = _rel_children_parent.a_to_b(viewonly=True)


class Child(Base):
    __tablename__ = "child"

    id = sa.Column(sa.Integer, primary_key=True)
    parent_id = sa.Column(sa.ForeignKey("parent.id"))

    parent = _rel_children_parent.b_to_a(viewonly=True)
property _cached_relationship_kwargs[source]
property _cached_relationship_kwargs_keys[source]
_make_relationship(case, kwargs)[source]
_make_relationship_kwargs(keys_only)[source]
_make_relationship_lazy_kwargs(case)[source]
a_to_b(**kwargs)[source]
b_to_a(**kwargs)[source]
kwargs: dict
names: dict[str, str]
primary: Callable
secondary: Optional[Callable] = None
tables: Callable
class sqlalchemy_boltons.orm.RemoteWrapper(_object_)[source]

Bases: object

_object_: object
sqlalchemy_boltons.orm.join_expr(right, relationship)[source]

Turn an ORM relationship into an expression that you can use for filtering.

sqlalchemy_boltons.reset module

exception sqlalchemy_boltons.reset.UnsupportedDialectError[source]

Bases: ValueError

sqlalchemy_boltons.reset.install_reset_auto(engine)[source]

Install the reset event handler for engine. This function automatically detects the right resetter to install, and raises an exception if the SQL dialect is not supported.

Important: You should disable the default reset handler (which just does a rollback) using create_engine(..., pool_reset_on_return=False).

Return type:

None

sqlalchemy_boltons.reset.install_reset_generic(engine)[source]

Default resetter which only does a rollback.

sqlalchemy_boltons.reset.install_reset_mssql(engine)[source]

This calls a semi-documented stored procedure called “sys.sp_reset_connection” which does lots of cleanup actions.

References:

sqlalchemy_boltons.reset.install_reset_postgresql(engine)[source]

Postgresql requires additional commands to end all transactions in progress and discard temporary tables.

References:

sqlalchemy_boltons.reset.is_safe_to_execute_sql(dbapi_connection, connection_record, reset_state)[source]
sqlalchemy_boltons.reset.register_resetter(name)[source]

sqlalchemy_boltons.slow module

class sqlalchemy_boltons.slow.LongTransactionDetector(timeout, capture_stack_on_begin=False, info_key='sqlalchemy_boltons.slow')[source]

Bases: object

static _now()[source]
capture_stack()[source]
capture_stack_on_begin: bool = False
format_stack(stack_info)[source]
info_key: str = 'sqlalchemy_boltons.slow'
on_begin(conn)[source]
on_end(conn)[source]
register(engine)[source]
timeout: float

sqlalchemy_boltons.sqlite module

class sqlalchemy_boltons.sqlite.Begin(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

https://www.sqlite.org/lang_transaction.html

Note that CONCURRENT is only available on a specific SQLite branch, not mainline.

CONCURRENT = 4
DEFERRED = 1
EXCLUSIVE = 3
IMMEDIATE = 2
class sqlalchemy_boltons.sqlite.ForeignKeys(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

https://www.sqlite.org/pragma.html#pragma_foreign_keys

DEFERRED = 2
IMMEDIATE = 3
OFF = 1
class sqlalchemy_boltons.sqlite.Journal(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

https://www.sqlite.org/pragma.html#pragma_journal_mode

Note that WAL2 is only available on a specific SQLite branch, not mainline.

DELETE = 1
MEMORY = 4
OFF = 7
PERSIST = 3
TRUNCATE = 2
WAL = 5
WAL2 = 6
class sqlalchemy_boltons.sqlite.Memory[source]

Bases: object

We keep a reference to an open connection because SQLite will free up the database otherwise. You must hold a reference to this object or else the database will be freed.

Note that you still can’t get concurrent readers and writers because you cannot currently set WAL mode on an in-memory database. See https://sqlite.org/forum/info/6700ab1f9f6e8a00

as_uri()[source]
connection_reference = None
uri: str
exception sqlalchemy_boltons.sqlite.MissingExecutionOptionError[source]

Bases: ValueError

class sqlalchemy_boltons.sqlite.Options(*, timeout, begin, foreign_keys, recursive_triggers, trusted_schema, schemas, encoding='UTF-8', ignore_check_constraints=False)[source]

Bases: _OptionsMixin

Represents the options that are applied to a SQLite database connection at the start of every transaction. These options are mostly in the form of “PRAGMA” statements.

Use new() as a convenient constructor that automatically resolves strings to enum values.

Parameters:
  • timeout (float | int | None) – Number of seconds to wait when a table is locked. Set this to None if you are using your own custom busy handler via sqlite3_busy_handler. See https://www.sqlite.org/c3ref/busy_timeout.html for more.

  • begin (Begin) – Controls the type of transaction. Use DEFERRED for read-only transactions and IMMEDIATE for read-write transactions.

  • foreign_keys (ForeignKeys) – Controls the enforcement of foreign keys.

  • trusted_schema (bool) – Can we trust the database schema? Set this to False if the database file comes from an untrusted source. See https://www.sqlite.org/src/doc/latest/doc/trusted-schema.md for more information.

  • recursive_triggers (bool) – Can the execution of a database trigger also cause the execution of another database trigger, and so on? This feature was added in SQLite in 2009, but it is turned off by default as it is a breaking change.

  • schemas (immutabledict[str, SchemaOptions]) – Contains per-schema configuration options. See SchemaOptions. You should have at least one entry for the “main” database.

  • encoding (str) – Encoding used for the text. Only a few values are supported according to https://www.sqlite.org/pragma.html#pragma_encoding and it can only be set on a brand new database.

  • ignore_check_constraints (bool) – This option can be used to temporarily disable CHECK constraints.

_cached_begin_commands: ClassVar[None | tuple[str, ...]] = None
_cached_generate_begin_commands()[source]
_generate_begin_commands()[source]
apply(configurable)[source]
Parameters:

configurable (Engine | Any) – Engine or connection that will be configured to use this Options object.

classmethod apply_lambda(configurable, function)[source]

Get the current options for configurable, pass them to function to produce a new options object, then apply() those options to configurable.

Parameters:
  • configurable (Engine | Any) – Engine or connection for which the Options will be updated.

  • function (Callable[[Options], Options]) – Function which accepts the current Options and produces a new Options object that will replace it inside configurable.

begin: Begin
static convert_kwargs(kw)[source]

This method is called to modify the current constructor keyword arguments in-place. Typically this is done to convert strings to enum members using _convert_enum().

encoding: str = 'UTF-8'
evolve(**kw)

Make a copy of the current options block but with keyword arguments **changes applied to replace some of the attributes.

evolve_schema(schema_name, **changes)[source]

Make a copy of the current options block but with keyword arguments **changes applied to schemas[schema_name] using SchemaOptions.evolve().

Parameters:
  • schema_name (str) – Name of the SchemaOptions that will be updated (by making a new copy).

  • **changes – Changes to be made to the SchemaOptions.

foreign_keys: ForeignKeys
classmethod get(configurable)[source]

Return the options configured on configurable. Raises KeyError if none is set.

Parameters:

configurable (Engine | Any) – Engine or connection for which the options will be retrieved.

Return type:

Options

ignore_check_constraints: bool = False
classmethod new(**kw)

Alternative constructor which automatically converts strings into enum values.

recursive_triggers: bool
schemas: immutabledict[str, SchemaOptions]
timeout: float | int | None
trusted_schema: bool
class sqlalchemy_boltons.sqlite.SQLAlchemySqliteTransactionFix[source]

Bases: object

This class exists because sqlalchemy doesn’t automatically fix pysqlite’s stupid default behaviour. Additionally, we implement support for foreign keys and other options.

Use Options.new() to construct the options and then Options.apply() them to your sa.Engine.

https://docs.sqlalchemy.org/en/20/dialects/sqlite.html#serializable-isolation-savepoints-transactional-ddl

event_begin(conn)[source]
event_connect(dbapi_connection, connection_record)[source]
register(engine)[source]
class sqlalchemy_boltons.sqlite.SchemaOptions(*, synchronous, journal=None, journal_size_limit=None, secure_delete=SecureDelete.OFF)[source]

Bases: _OptionsMixin

Options specific to one schema (one ATTACHed database file).

Use new() as a convenient constructor that automatically resolves strings to enum values.

Parameters:
  • synchronous (Synchronous) – Higher levels are slower but provide more resilience to corruption in case of a sudden power failure or crash. Conversely, lower levels can be faster by orders of magnitude, at the cost of likely corruption in case of an unexpected power failure.

  • journal (Journal | None) – Journal mode. WAL is usually a good choice.

  • journal_size_limit (int | None) – The journal file may be left in place after a transaction ends, depending on your settings. To avoid it from taking up too much space, this option tells SQLite to trim down the journal file size down to journal_size_limit after the end of a transaction. Use 0 to trim it down to its minimum size. Use -1 to allow it to grow unbounded.

  • secure_delete (SecureDelete) – Controls the “overwrite with zeros” anti-forensic mechanism. Note that there are still some caveats, which you should read about at https://www.sqlite.org/pragma.html#pragma_secure_delete

static convert_kwargs(kw)[source]

This method is called to modify the current constructor keyword arguments in-place. Typically this is done to convert strings to enum members using _convert_enum().

evolve(**kw)

Make a copy of the current options block but with keyword arguments **changes applied to replace some of the attributes.

journal: Journal | None = None
journal_size_limit: int | None = None
classmethod new(**kw)

Alternative constructor which automatically converts strings into enum values.

secure_delete: SecureDelete = 1
synchronous: Synchronous
class sqlalchemy_boltons.sqlite.SecureDelete(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

https://www.sqlite.org/pragma.html#pragma_secure_delete

FAST = 2
OFF = 1
ON = 3
class sqlalchemy_boltons.sqlite.Synchronous(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

https://www.sqlite.org/pragma.html#pragma_synchronous

EXTRA = 4
FULL = 3
NORMAL = 2
OFF = 1
class sqlalchemy_boltons.sqlite._OptionsMixin[source]

Bases: ABC

Common constructor code used for both Options and SchemaOptions.

abstract convert_kwargs(kw)[source]

This method is called to modify the current constructor keyword arguments in-place. Typically this is done to convert strings to enum members using _convert_enum().

evolve(**kw)[source]

Make a copy of the current options block but with keyword arguments **changes applied to replace some of the attributes.

classmethod new(**kw)[source]

Alternative constructor which automatically converts strings into enum values.

sqlalchemy_boltons.sqlite._convert_enum(d, k, enum_class)[source]
sqlalchemy_boltons.sqlite.create_engine_sqlite(path, *, parameters=(), check_same_thread=False, create_engine_args=None, create_engine=None, transaction_fix=True)[source]

Create a sqlite engine.

Parameters:
Return type:

Engine

sqlalchemy_boltons.sqlite.sqlite_file_uri(path, parameters=())[source]
Return type:

str

sqlalchemy_boltons.temporary module

class sqlalchemy_boltons.temporary.CacheTemporaryMetaData(creator_function, global_prefix='tmp__')[source]

Bases: Generic[T]

This holds a cache of the generated metadata (tables, indices, etc).

Calling an instance gives you a context manager that creates a temporary table which is valid within the current “with” block. The temporary table is dropped as soon as the “with” block completes.

By default, this function creates the table in a brand new sqlalchemy.MetaData. If you want to create the table inside an existing one, then pass in the metadata argument.

If you want something that persists past the end of the transaction, then you probably want an actual persistent table. If you think about it some more, you will realize that you probably also want some way to keep track of these semi-persistent tables, and automatically discard them if they are too old. We will someday provide a way to do that too, maybe.

Tested on SQLite, Postgres, and MariaDB/MySQL.

Based on https://github.com/sqlalchemy/sqlalchemy/discussions/9400

static _bind_to_connection(bind)[source]
_make_new(cls, dialect, naming)[source]
creator_function: Union[Table, Callable[[TemporaryMetaDataMaker], TypeVar(T)]]
get(bind, prefix, suffix='', cache=True)[source]
Return type:

MetaDataMakerResult[TypeVar(T)]

global_prefix: str = 'tmp__'
class sqlalchemy_boltons.temporary.MetaDataMaker[source]

Bases: ABC

static _as_table(table)[source]
_init_metadata()[source]
_make_metadata_kwargs()[source]
abstract configure_table(table)[source]

This method is called to fully configure a table.

Return type:

None

abstract copy_table(table, name=None, referred_schema_fn=None)[source]

Make a copy of an existing table using sa.Table.to_metadata().

Subclasses must choose to support this method or raise NotImplementedError.

Return type:

Table

finish()[source]

You must call this method after adding all the tables.

metadata: MetaData
run(function)[source]
Return type:

MetaDataMakerResult[TypeVar(T)]

table(name, *args, **kwargs)[source]

Create a table associated with metadata.

Return type:

Table

abstract table_name(name)[source]

Return the transformed table name. Usually a prefix and/or suffix are added.

Return type:

str

class sqlalchemy_boltons.temporary.MetaDataMakerMixinUseDefaultCopyTable[source]

Bases: MetaDataMaker

static _as_table(table)
_init_metadata()
_make_metadata_kwargs()
abstract configure_table(table)

This method is called to fully configure a table.

Return type:

None

copy_table(*args, **kwargs)[source]

Make a copy of an existing table using sa.Table.to_metadata().

Subclasses must choose to support this method or raise NotImplementedError.

finish()

You must call this method after adding all the tables.

metadata: MetaData
run(function)
Return type:

MetaDataMakerResult[TypeVar(T)]

table(name, *args, **kwargs)

Create a table associated with metadata.

Return type:

Table

abstract table_name(name)

Return the transformed table name. Usually a prefix and/or suffix are added.

Return type:

str

class sqlalchemy_boltons.temporary.MetaDataMakerResult(maker, value)[source]

Bases: Generic[T]

enter(bind)[source]
maker: MetaDataMaker
value: TypeVar(T)
class sqlalchemy_boltons.temporary.Naming(prefix, suffix)[source]

Bases: object

prefix: str
suffix: str
class sqlalchemy_boltons.temporary.TemporaryMetaDataMaker(dialect, naming)[source]

Bases: MetaDataMaker, ABC

AUTO_REGISTER = True
DIALECT_NAME_TO_CLASS = {'mariadb': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mariadb'>, 'mysql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mysql'>, 'postgresql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_postgresql'>, 'sqlite': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_sqlite'>}
static _as_table(table)
_init_metadata()
_make_metadata_kwargs()
abstract configure_table(table)

This method is called to fully configure a table.

Return type:

None

abstract copy_table(table, name=None, referred_schema_fn=None)

Make a copy of an existing table using sa.Table.to_metadata().

Subclasses must choose to support this method or raise NotImplementedError.

Return type:

Table

dialect: Dialect
finish()

You must call this method after adding all the tables.

classmethod get_class_for_engine(engine)[source]
metadata: MetaData
naming: Callable[[str], str]
classmethod register_fallback_for_dialect(dialect)[source]
run(function)
Return type:

MetaDataMakerResult[TypeVar(T)]

table(name, *args, **kwargs)

Create a table associated with metadata.

Return type:

Table

table_name(name)[source]

Return the transformed table name. Usually a prefix and/or suffix are added.

class sqlalchemy_boltons.temporary.TemporaryMetaDataMakerFallback(dialect, naming)[source]

Bases: TemporaryMetaDataMaker, MetaDataMakerMixinUseDefaultCopyTable

AUTO_REGISTER = False
DIALECT_NAME_TO_CLASS = {'mariadb': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mariadb'>, 'mysql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mysql'>, 'postgresql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_postgresql'>, 'sqlite': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_sqlite'>}
static _as_table(table)
_init_metadata()
_make_metadata_kwargs()
abstract configure_table(table)

This method is called to fully configure a table.

Return type:

None

copy_table(*args, **kwargs)

Make a copy of an existing table using sa.Table.to_metadata().

Subclasses must choose to support this method or raise NotImplementedError.

dialect: Dialect
finish()

You must call this method after adding all the tables.

classmethod get_class_for_engine(engine)
metadata: MetaData
naming: Callable[[str], str]
classmethod register_fallback_for_dialect(dialect)
run(function)
Return type:

MetaDataMakerResult[TypeVar(T)]

table(name, *args, **kwargs)

Create a table associated with metadata.

Return type:

Table

table_name(*a, **kw)[source]

Return the transformed table name. Usually a prefix and/or suffix are added.

class sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mariadb(dialect, naming)[source]

Bases: TemporaryMetaDataMaker, MetaDataMakerMixinUseDefaultCopyTable

AUTO_REGISTER = True
DIALECT_NAME_TO_CLASS = {'mariadb': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mariadb'>, 'mysql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mysql'>, 'postgresql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_postgresql'>, 'sqlite': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_sqlite'>}
static _as_table(table)
_init_metadata()
_make_metadata_kwargs()
classmethod configure_table(table)[source]

This method is called to fully configure a table.

copy_table(*args, **kwargs)

Make a copy of an existing table using sa.Table.to_metadata().

Subclasses must choose to support this method or raise NotImplementedError.

dialect: Dialect
finish()

You must call this method after adding all the tables.

classmethod get_class_for_engine(engine)
metadata: MetaData
naming: Callable[[str], str]
classmethod register_fallback_for_dialect(dialect)
run(function)
Return type:

MetaDataMakerResult[TypeVar(T)]

table(name, *args, **kwargs)

Create a table associated with metadata.

Return type:

Table

table_name(name)

Return the transformed table name. Usually a prefix and/or suffix are added.

class sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mysql(dialect, naming)[source]

Bases: TemporaryMetaDataMaker_mariadb

AUTO_REGISTER = True
DIALECT_NAME_TO_CLASS = {'mariadb': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mariadb'>, 'mysql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mysql'>, 'postgresql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_postgresql'>, 'sqlite': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_sqlite'>}
static _as_table(table)
_init_metadata()
_make_metadata_kwargs()
classmethod configure_table(table)

This method is called to fully configure a table.

copy_table(*args, **kwargs)

Make a copy of an existing table using sa.Table.to_metadata().

Subclasses must choose to support this method or raise NotImplementedError.

dialect: Dialect
finish()

You must call this method after adding all the tables.

classmethod get_class_for_engine(engine)
metadata: MetaData
naming: Callable[[str], str]
classmethod register_fallback_for_dialect(dialect)
run(function)
Return type:

MetaDataMakerResult[TypeVar(T)]

table(name, *args, **kwargs)

Create a table associated with metadata.

Return type:

Table

table_name(name)

Return the transformed table name. Usually a prefix and/or suffix are added.

class sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_postgresql(dialect, naming)[source]

Bases: TemporaryMetaDataMaker, MetaDataMakerMixinUseDefaultCopyTable

AUTO_REGISTER = True
DIALECT_NAME_TO_CLASS = {'mariadb': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mariadb'>, 'mysql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mysql'>, 'postgresql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_postgresql'>, 'sqlite': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_sqlite'>}
static _as_table(table)
_init_metadata()
_make_metadata_kwargs()
classmethod configure_table(table)[source]

This method is called to fully configure a table.

copy_table(*args, **kwargs)

Make a copy of an existing table using sa.Table.to_metadata().

Subclasses must choose to support this method or raise NotImplementedError.

dialect: Dialect
finish()

You must call this method after adding all the tables.

classmethod get_class_for_engine(engine)
metadata: MetaData
naming: Callable[[str], str]
classmethod register_fallback_for_dialect(dialect)
run(function)
Return type:

MetaDataMakerResult[TypeVar(T)]

table(name, *args, **kwargs)

Create a table associated with metadata.

Return type:

Table

table_name(name)

Return the transformed table name. Usually a prefix and/or suffix are added.

class sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_sqlite(dialect, naming)[source]

Bases: TemporaryMetaDataMaker, MetaDataMakerMixinUseDefaultCopyTable

AUTO_REGISTER = True
DIALECT_NAME_TO_CLASS = {'mariadb': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mariadb'>, 'mysql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_mysql'>, 'postgresql': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_postgresql'>, 'sqlite': <class 'sqlalchemy_boltons.temporary.TemporaryMetaDataMaker_sqlite'>}
static _as_table(table)
_init_metadata()
_make_metadata_kwargs()
classmethod configure_table(table)[source]

This method is called to fully configure a table.

copy_table(*args, **kwargs)

Make a copy of an existing table using sa.Table.to_metadata().

Subclasses must choose to support this method or raise NotImplementedError.

dialect: Dialect
finish()

You must call this method after adding all the tables.

classmethod get_class_for_engine(engine)
metadata: MetaData
naming: Callable[[str], str]
classmethod register_fallback_for_dialect(dialect)
run(function)
Return type:

MetaDataMakerResult[TypeVar(T)]

table(name, *args, **kwargs)

Create a table associated with metadata.

Return type:

Table

table_name(name)

Return the transformed table name. Usually a prefix and/or suffix are added.

exception sqlalchemy_boltons.temporary.UnsupportedDialectError[source]

Bases: ValueError

Module contents