engine¶
- class advanced_alchemy.config.engine.EngineConfig[source]¶
Bases:
object
Configuration for SQLAlchemy’s Engine.
This class provides configuration options for SQLAlchemy engine creation. See: https://docs.sqlalchemy.org/en/20/core/engines.html
- connect_args¶
A dictionary of arguments which will be passed directly to the DBAPI’s
connect()
method as keyword arguments.alias of
Empty
- echo¶
If
True
, the Engine will log all statements as well as arepr()
of their parameter lists to the default log handler, which defaults tosys.stdout
for output. If set to the string “debug”, result rows will be printed to the standard output as well. The echo attribute of Engine can be modified at any time to turn logging on and off; direct control of logging is also available using the standard Python logging module.alias of
Empty
- echo_pool¶
If
True
, the connection pool will log informational output such as when connections are invalidated as well as when connections are recycled to the default log handler, which defaults to sys.stdout for output. If set to the string “debug”, the logging will include pool checkouts and checkins. Direct control of logging is also available using the standard Python logging module.alias of
Empty
- enable_from_linting¶
Defaults to True. Will emit a warning if a given SELECT statement is found to have un-linked FROM elements which would cause a cartesian product.
alias of
Empty
- execution_options¶
Dictionary execution options which will be applied to all connections. See
Connection.execution_options()
for details.alias of
Empty
- hide_parameters¶
Boolean, when set to
True
, SQL statement parameters will not be displayed in INFO logging nor will they be formatted into the string representation ofStatementError
objects.alias of
Empty
- insertmanyvalues_page_size¶
Number of rows to format into an INSERT statement when the statement uses “insertmanyvalues” mode, which is a paged form of bulk insert that is used for many backends when using executemany execution typically in conjunction with RETURNING. Defaults to 1000, but may also be subject to dialect-specific limiting factors which may override this value on a per-statement basis.
alias of
Empty
- isolation_level¶
Optional string name of an isolation level which will be set on all new connections unconditionally. Isolation levels are typically some subset of the string names “SERIALIZABLE”, “REPEATABLE READ”, “READ COMMITTED”, “READ UNCOMMITTED” and “AUTOCOMMIT” based on backend.
alias of
Empty
- json_deserializer(buf)¶
For dialects that support the
JSON
datatype, this is a Python callable that will convert a JSON string to a Python object. By default, this is set to Litestar’sdecode_json()
function.
- json_serializer() str ¶
For dialects that support the JSON datatype, this is a Python callable that will render a given object as JSON. By default, Litestar’s
encode_json()
is used.
- label_length¶
Optional integer value which limits the size of dynamically generated column labels to that many characters. If less than 6, labels are generated as “_(counter)”. If
None
, the value ofdialect.max_identifier_length
, which may be affected via theget_engine.max_identifier_length parameter
, is used instead. The value ofget_engine.label_length
may not be larger than that ofget_engine.max_identifier_length
.alias of
Empty
- logging_name¶
String identifier which will be used within the “name” field of logging records generated within the “sqlalchemy.engine” logger. Defaults to a hexstring of the object`s id.
alias of
Empty
- max_identifier_length¶
Override the max_identifier_length determined by the dialect. if
None
or0
, has no effect. This is the database`s configured maximum number of characters that may be used in a SQL identifier such as a table name, column name, or label name. All dialects determine this value automatically, however in the case of a new database version for which this value has changed but SQLAlchemy`s dialect has not been adjusted, the value may be passed here.alias of
Empty
- max_overflow¶
The number of connections to allow in connection pool “overflow”, that is connections that can be opened above and beyond the pool_size setting, which defaults to five. This is only used with
QueuePool
.alias of
Empty
- __init__(connect_args: dict[Any, Any] | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, echo: _EchoFlagType | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, echo_pool: _EchoFlagType | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, enable_from_linting: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, execution_options: Mapping[str, Any] | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, hide_parameters: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, insertmanyvalues_page_size: int | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, isolation_level: IsolationLevel | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, json_deserializer: Callable[[str], Any] = <built-in method decode of msgspec.json.Decoder object>, json_serializer: Callable[[Any], str] = <function encode_json>, label_length: int | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, logging_name: str | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, max_identifier_length: int | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, max_overflow: int | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, module: Any | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, paramstyle: _ParamStyle | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, pool: Pool | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, poolclass: type[Pool] | None | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, pool_logging_name: str | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, pool_pre_ping: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, pool_size: int | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, pool_recycle: int | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, pool_reset_on_return: Literal['rollback', 'commit'] | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, pool_timeout: int | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, pool_use_lifo: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, plugins: list[str] | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, query_cache_size: int | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>, use_insertmanyvalues: bool | EmptyType = <class 'advanced_alchemy.utils.dataclass.Empty'>) None ¶
- module¶
Reference to a Python module object (the module itself, not its string name). Specifies an alternate DBAPI module to be used by the engine`s dialect. Each sub-dialect references a specific DBAPI which will be imported before first connect. This parameter causes the import to be bypassed, and the given module to be used instead. Can be used for testing of DBAPIs as well as to inject “mock” DBAPI implementations into the
Engine
.alias of
Empty
- paramstyle¶
The paramstyle to use when rendering bound parameters. This style defaults to the one recommended by the DBAPI itself, which is retrieved from the
.paramstyle
attribute of the DBAPI. However, most DBAPIs accept more than one paramstyle, and in particular it may be desirable to change a “named” paramstyle into a “positional” one, or vice versa. When this attribute is passed, it should be one of the values “qmark”, “numeric”, “named”, “format” or “pyformat”, and should correspond to a parameter style known to be supported by the DBAPI in use.alias of
Empty
- pool¶
An already-constructed instance of
Pool
, such as aQueuePool
instance. If non-None, this pool will be used directly as the underlying connection pool for the engine, bypassing whatever connection parameters are present in the URL argument. For information on constructing connection pools manually, see Connection Pooling.alias of
Empty
- poolclass¶
A
Pool
subclass, which will be used to create a connection pool instance using the connection parameters given in the URL. Note this differs from pool in that you don`t actually instantiate the pool in this case, you just indicate what type of pool to be used.alias of
Empty
- pool_logging_name¶
String identifier which will be used within the “name” field of logging records generated within the “sqlalchemy.pool” logger. Defaults to a hexstring of the object`s id.
alias of
Empty
- pool_pre_ping¶
If True will enable the connection pool “pre-ping” feature that tests connections for liveness upon each checkout.
alias of
Empty
- pool_size¶
The number of connections to keep open inside the connection pool. This used with
QueuePool
as well asSingletonThreadPool
. WithQueuePool
, a pool_size setting of0
indicates no limit; to disable pooling, setpoolclass
toNullPool
instead.alias of
Empty
- pool_recycle¶
This setting causes the pool to recycle connections after the given number of seconds has passed. It defaults to
-1
, or no timeout. For example, setting to3600
means connections will be recycled after one hour. Note that MySQL in particular will disconnect automatically if no activity is detected on a connection for eight hours (although this is configurable with the MySQLDB connection itself and the server configuration as well).alias of
Empty
- pool_reset_on_return¶
Set the
Pool.reset_on_return <sqlalchemy.pool.Pool.params.reset_on_return
parameter of the underlying :class`Pool <sqlalchemy.pool.Pool>` object, which can be set to the values"rollback"
,"commit"
, orNone
.alias of
Empty
- pool_timeout¶
Number of seconds to wait before giving up on getting a connection from the pool. This is only used with
QueuePool
. This can be a float but is subject to the limitations of Python time functions which may not be reliable in the tens of milliseconds.alias of
Empty
- pool_use_lifo¶
Use LIFO (last-in-first-out) when retrieving connections from
QueuePool
instead of FIFO (first-in-first-out). Using LIFO, a server-side timeout scheme can reduce the number of connections used during non-peak periods of use. When planning for server-side timeouts, ensure that a recycle or pre-ping strategy is in use to gracefully handle stale connections.alias of
Empty
- plugins¶
String list of plugin names to load. See
CreateEnginePlugin
for background.alias of
Empty