gensaschema._table module¶
Table inspection and representation¶
Table inspection and representation
- Copyright:
Copyright 2010 - 2023 André Malo or his licensors, as applicable
- License:
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class gensaschema._table.Table(varname, table, schemas, symbols)[source]¶
Reflected table
- varname¶
Variable name
- Type:
str
- sa_table¶
Table
- Type:
sqlalchemy.Table
- constraints¶
Constraint list
- Type:
list
- _symbols¶
Symbol table
- Type:
- __dict__ = mappingproxy({'__module__': 'gensaschema._table', '__doc__': '\n Reflected table\n\n\n Attributes:\n varname (str):\n Variable name\n\n sa_table (sqlalchemy.Table):\n Table\n\n constraints (list):\n Constraint list\n\n _symbols (Symbols):\n Symbol table\n ', 'is_reference': False, '__new__': <staticmethod(<function Table.__new__>)>, '__init__': <function Table.__init__>, 'by_name': <classmethod(<function Table.by_name>)>, '__repr__': <function Table.__repr__>, '__dict__': <attribute '__dict__' of 'Table' objects>, '__weakref__': <attribute '__weakref__' of 'Table' objects>, '__annotations__': {}})¶
- __init__(varname, table, schemas, symbols)[source]¶
Initialization
- Parameters:
varname (
str
) – Variable nametable (
sqlalchemy.Table
) – Tableschemas (
dict
) – Schema -> module mappingsymbols (gensaschema.Symbols) – Symbol table
- __module__ = 'gensaschema._table'¶
- static __new__(cls, varname, table, schemas, symbols)[source]¶
Construct
This might actually return a table reference
- Parameters:
varname (
str
) – Variable nametable (
sqlalchemy.Table
) – Tableschemas (
dict
) – Schema -> module mappingsymbols (gensaschema.Symbols) – Symbol table
- Returns:
New instance
- Return type:
- __weakref__¶
list of weak references to the object (if defined)
- classmethod by_name(name, varname, metadata, schemas, symbols, types=None)[source]¶
Construct by name
- Parameters:
name (
str
) – Table name (possibly qualified)varname (
str
) – Variable name of the tablemetadata (
SA (bound) metadata
) – Metadata containerschemas (
dict
) – Schema -> module mappingsymbols (gensaschema.Symbols) – Symbol table
types (
callable
) – Extra type loader. If the type reflection fails, because SQLAlchemy cannot resolve it, the type loader will be called with the type name, (bound) metadata and the symbol table. It is responsible for modifying the symbols and imports and the dialect’sischema_names
. If omitted orNone
, the reflector will always fail on unknown types.
- Returns:
new Table instance
- Return type:
- is_reference = False¶
Is it a table reference (vs. a table)?
- Type:
bool
- class gensaschema._table.TableCollection(iterable=(), /)[source]¶
Table collection
- __dict__ = mappingproxy({'__module__': 'gensaschema._table', '__doc__': 'Table collection', 'by_names': <classmethod(<function TableCollection.by_names>)>, '__dict__': <attribute '__dict__' of 'TableCollection' objects>, '__annotations__': {}})¶
- __module__ = 'gensaschema._table'¶
- classmethod by_names(metadata, names, schemas, symbols, types=None)[source]¶
Construct by table names
- Parameters:
metadata (
sqlalchemy.MetaData
) – Metadatanames (
iterable
) – Name list (list of tuples (varname, name))symbols (gensaschema.Symbols) – Symbol table
types (
callable
) – Extra type loader. If the type reflection fails, because SQLAlchemy cannot resolve it, the type loader will be called with the type name, (bound) metadata and the symbol table. It is responsible for modifying the symbols and imports and the dialect’sischema_names
. If omitted orNone
, the reflector will always fail on unknown types.
- Returns:
New table collection instance
- Return type:
- class gensaschema._table.TableReference(varname, table, schema, symbols)[source]¶
Referenced table
- varname¶
Variable name
- Type:
str
- sa_table¶
Table
- Type:
sqlalchemy.Table
- constraints¶
Constraint list
- Type:
list
- __dict__ = mappingproxy({'__module__': 'gensaschema._table', '__doc__': '\n Referenced table\n\n Attributes:\n varname (str):\n Variable name\n\n sa_table (sqlalchemy.Table):\n Table\n\n constraints (list):\n Constraint list\n ', 'is_reference': True, '__init__': <function TableReference.__init__>, '__dict__': <attribute '__dict__' of 'TableReference' objects>, '__weakref__': <attribute '__weakref__' of 'TableReference' objects>, '__annotations__': {}})¶
- __init__(varname, table, schema, symbols)[source]¶
Initialization
- Parameters:
varname (
str
) – Variable nametable (
sqlalchemy.Table
) – Tablesymbols (gensaschema.Symbols) – Symbol table
- __module__ = 'gensaschema._table'¶
- __weakref__¶
list of weak references to the object (if defined)
- is_reference = True¶
Is it a table reference (vs. a table)?
- Type:
bool