Miscellaneous Model Arguments¶
SQLAlchemy allows for special parameters, such as __mapper_args__
that
change the behavior of a model. OpenAlchemy supports this by adding the
x-kwargs
extension property for a schema. For example, the following
schema defines __mapper_args__
for the Employee schema:
1 2 3 4 5 6 | Employee: type: object ... x-kwargs: __mapper_args__: polymorphic_identity: employee |
Note that the following restrictions apply:
the value must be an object,
the keys of the object must be strings,
the keys must start and end with
__
andkeys cannot be:
__tablename__
and__table_args__
.
Also note that no verification, beyond the above, is done before adding the kwargs to the SQLAlchemy model.
Define Custom Schema name¶
With some databases you can group tables into schemas. OpenAlchemy supports
this with the model extension property x-schema-name
that is optionally
defined alongside __tablename__
. It takes the name of the schema, for
example, the string company
.
See also
- SQLAlchemy specifying the schema name
Documentation for defining the schema name.