gensaschema._constraint module

Constraint inspection and representation

Constraint 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._constraint.Constraint(constraint, table, symbols, options=None)[source]

Reflected Constraint

constraint

Constraint

Type:

SA Constraint

_IMPORT = None
_SYMBOL = None
__cmp__(other)[source]

Compare

__dict__ = mappingproxy({'__module__': 'gensaschema._constraint', '__doc__': '\n    Reflected Constraint\n\n    Attributes:\n      constraint (SA Constraint):\n        Constraint\n    ', '_SYMBOL': None, '_IMPORT': None, '__new__': <staticmethod(<function Constraint.__new__>)>, '__init__': <function Constraint.__init__>, 'copy': <function Constraint.copy>, '__cmp__': <function Constraint.__cmp__>, '__lt__': <function Constraint.__lt__>, 'repr': <function Constraint.repr>, '__dict__': <attribute '__dict__' of 'Constraint' objects>, '__weakref__': <attribute '__weakref__' of 'Constraint' objects>, '__annotations__': {}})
__init__(constraint, table, symbols, options=None)[source]

Initialization

Parameters:
  • constraint (SA Constraint) – Constraint

  • table (str) – Table varname

  • symbols (gensaschema.Symbols) – Symbol table

  • options (str) – Options

__lt__(other, _cmp=<function Constraint.__cmp__>)[source]

Check for ‘<’

__module__ = 'gensaschema._constraint'
static __new__(cls, constraint, table, symbols, options=None)[source]

Constraint factory

__weakref__

list of weak references to the object (if defined)

copy()[source]

Create shallow copy

repr(symbol, args, keywords=(), short=False)[source]

Base repr for all constraints

Parameters:
  • symbol (str) – Symbol name

  • args (iterable) – Positional arguments

  • keywords (iterable) – Keywords arguments to specify

  • short (bool) – Short representation (i.e. one-line)? Only applied if there are not too many parameters.

Returns:

The constraint repr

Return type:

str

class gensaschema._constraint.ForeignKeyConstraint(constraint, table, symbols, options=None)[source]

ForeignKey constraint

_IMPORT = 'from %(constraints)s import ForeignKey as %(fk)s'
_SYMBOL = 'fk'
__annotations__ = {}
__module__ = 'gensaschema._constraint'
__repr__()[source]

Make string representation

Returns:

The string representation

Return type:

str

class gensaschema._constraint.PrimaryKeyConstraint(constraint, table, symbols, options=None)[source]

Primary Key constraint

_IMPORT = 'from %(constraints)s import PrimaryKey as %(pk)s'
_SYMBOL = 'pk'
__annotations__ = {}
__module__ = 'gensaschema._constraint'
class gensaschema._constraint.UniqueConstraint(constraint, table, symbols, options=None)[source]

Unique constraint

_IMPORT = 'from %(constraints)s import Unique as %(uk)s'
_SYMBOL = 'uk'
__annotations__ = {}
__module__ = 'gensaschema._constraint'
__repr__()[source]

Make string representation

Returns:

The string representation

Return type:

str

gensaschema._constraint.access_col(col)[source]

Generate column access string (either as attribute or via dict access)

Parameters:

col (SA Column) – Column

Returns:

Access string

Return type:

str