:tocdepth: 3 :py:mod:`gws.base.database.provider` ==================================== .. py:module:: gws.base.database.provider **Source code:** :source:`gws.base.database.provider` Module Contents --------------- .. py:class:: Config(*args, **kwargs) Bases: :py:obj:`gws.Config` Database provider .. py:attribute:: schemaCacheLifeTime :type: gws.Duration :value: 3600 life time for schema caches .. py:class:: Object Bases: :py:obj:`gws.DatabaseProvider` Database Provider. A database Provider wraps SQLAlchemy ``Engine`` and ``Connection`` objects and provides common db functionality. .. py:attribute:: SA_TO_ATTR .. py:attribute:: SA_TO_GEOM .. py:attribute:: saConnection :type: Optional[gws.lib.sa.Connection] .. py:attribute:: saConnectionCount :type: int .. py:attribute:: saEngine :type: gws.lib.sa.Engine .. py:attribute:: saMetaMap :type: dict[str, gws.lib.sa.MetaData] .. py:attribute:: UNKNOWN_ARRAY_TYPE .. py:attribute:: UNKNOWN_TYPE .. py:method:: activate() Activation hook. .. py:method:: column(table, column_name) SA ``Column`` object for a specific column. .. py:method:: configure() Configuration hook. .. py:method:: 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 .. py:method:: count(table) Return table record count or 0 if the table does not exist. .. py:method:: describe(table) Describe a table. .. py:method:: describe_column(table, column_name) -> gws.ColumnDescription .. py:method:: execute_text(sql, **kwargs) Execute a textual DML statement and return a result. .. py:method:: has_column(table, column_name) Check if a specific column exists. .. py:method:: has_table(table_name: str) Check if a specific table exists. .. py:method:: reflect_schema(schema: str) .. py:method:: select_text(sql, **kwargs) Execute a textual SELECT statement and return a list of record dicts. .. py:method:: table(table_name, **kwargs) SA ``Table`` object for a specific table.