gensaschema._schema module

Schema module generation

Schema module generation code.

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._schema.Schema(conn, tables, schemas, symbols, dbname=None, types=None)[source]

Schema container

_dialect

Dialect name

Type:

str

_tables

Table collection

Type:

TableCollection

_schemas

Schema -> module mapping

Type:

dict

_symbols

Symbol table

Type:

gensaschema.Symbols

_dbname

DB identifier

Type:

str or None

_MODULE_TPL = <gensaschema._template.Template object>

Template for the module

Type:

Template

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'gensaschema._schema', '__doc__': '\n    Schema container\n\n    Attributes:\n      _dialect (str):\n        Dialect name\n\n      _tables (TableCollection):\n        Table collection\n\n      _schemas (dict):\n        Schema -> module mapping\n\n      _symbols (Symbols):\n        Symbol table\n\n      _dbname (str or None):\n        DB identifier\n    ', '_MODULE_TPL': <gensaschema._template.Template object>, '__init__': <function Schema.__init__>, 'dump': <function Schema.dump>, '__dict__': <attribute '__dict__' of 'Schema' objects>, '__weakref__': <attribute '__weakref__' of 'Schema' objects>, '__annotations__': {}})
__init__(conn, tables, schemas, symbols, dbname=None, types=None)[source]

Initialization

Parameters:
  • conn (Connection or Engine) – SQLAlchemy connection or engine

  • tables (list) – List of tables to reflect, (local name, table name) pairs

  • schemas (dict) – schema -> module mapping

  • symbols (gensaschema.Symbols) – Symbol table

  • dbname (str) – Optional db identifier. Used for informational purposes. If omitted or None, the information just won’t be emitted.

  • 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’s ischema_names. If omitted or None, the reflector will always fail on unknown types.

__module__ = 'gensaschema._schema'
__weakref__

list of weak references to the object (if defined)

dump(fp)[source]

Dump schema module to fp

Parameters:

fp (file) – File to write to