kabupaten.py 721 Bytes
from sqlalchemy import (
    Column,
    String,
    ForeignKeyConstraint,
    )
from sqlalchemy.ext.declarative import declared_attr


class KabupatenMixin:
    @declared_attr
    def __tablename__(self):
        return 'ref_dati2'

    @declared_attr
    def kd_propinsi(self):
        return Column(String(2), primary_key=True)

    @declared_attr
    def kd_dati2(self):
        return Column(String(2), primary_key=True)

    @declared_attr
    def nm_dati2(self):
        return Column(String(30), nullable=False)

    @declared_attr
    def __table_args__(self):
        return (
            ForeignKeyConstraint(
                ['kd_propinsi'], ['pbb.ref_propinsi.kd_propinsi']),
            dict(schema='pbb'))