SQLAlchemy Converter

inverter provides converter from dataclass to SQLAlchemy ORM model.

Currently, only PostgreSQL compatible model is can be generated.

inverter.dc2pgsqla.convert(schema, metadata, *, name=None) → sqlalchemy.sql.schema.Table

Convert dataclass to sqlalchemy ORM model

Parameters
  • schemadataclass class

  • metadatasqlalchemy.MetaData object

  • name – model name

Returns

sqlalchemy ORM class

Field metadata handling

  • primary_key: bool - primary key flag

  • index: bool - flag on whether to index the column

  • autoincrement: bool - flag on whether to make column autoincrement

  • unique: bool - flag on whether to make column unique

  • searchable: bool - flag on whether to make column searchable using PGSQL Trigram

  • format: str - format of data: uuid, text, fulltextindex, bigint, numeric. This forces SQLAlchemy to use specific data type for the format.