Skip to content

Latest commit

 

History

History
38 lines (22 loc) · 739 Bytes

README.md

File metadata and controls

38 lines (22 loc) · 739 Bytes

SchemAlchemy

Schematics + SQLAlchemy

Usage

  1. Import schemalchemy (before schematics)
  2. Inherit from schemalchemy Base
  3. Define the SQLAlchemy columns (or provide a Table)
  4. Define the Schematics fields

Note: Column property names must be '_' + field_name (see about SQLAlchemy column_prefix if you need to customize the prefix).

Example

from schemalchemy import Base
from schematics.types import IntType, StringType
from sqlalchemy import Column, Integer, String


class Person(Base):

    __tablename__ = 'person'

    _id = Column('id', Integer, primary_key=True)
    _name = Column('name', String(50))

    id = IntType(default=1)
    name = StringType()