gws.base.database.provider
¶
Source code: gws.base.database.provider
Module Contents¶
- class gws.base.database.provider.Config(*args, **kwargs)¶
Bases:
gws.Config
Database provider
- schemaCacheLifeTime: gws.Duration = 3600¶
life time for schema caches
- class gws.base.database.provider.Object¶
Bases:
gws.DatabaseProvider
Database Provider.
A database Provider wraps SQLAlchemy
Engine
andConnection
objects and provides common db functionality.- SA_TO_ATTR¶
- SA_TO_GEOM¶
- saConnection: gws.lib.sa.Connection | None¶
- saConnectionCount: int¶
- saEngine: gws.lib.sa.Engine¶
- saMetaMap: dict[str, gws.lib.sa.MetaData]¶
- UNKNOWN_ARRAY_TYPE¶
- UNKNOWN_TYPE¶
- activate()¶
Activation hook.
- autoload(schema: str)¶
- column(table, column_name)¶
SA
Column
object for a specific column.
- configure()¶
Configuration hook.
- connect()¶
Context manager for a SA
Connection
.Context calls to this method can be nested. An inner call is a no-op, as no new connection is created. Only the outermost connection is closed upon exit:
with db.connect(): ... with db.connect(): # no-op ... # connection remains open ... # connection closed
- count(table)¶
Return table record count or 0 if the table does not exist.
- describe(table)¶
Describe a table.
- execute_text(sql, **kwargs)¶
Execute a textual DML statement and return a result.
- has_column(table, column_name)¶
Check if a specific column exists.
- has_table(table_name: str)¶
Check if a specific table exists.
- select_text(sql, **kwargs)¶
Execute a textual SELECT statement and return a list of record dicts.
- table(table_name, **kwargs)¶
SA
Table
object for a specific table.