Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sqlalchemy import Column, ForeignKey, UniqueConstraint, \
- String, Integer, BigInteger, Boolean, Numeric, create_engine
- from sqlalchemy.ext.declarative import declarative_base
- from sqlalchemy.orm import sessionmaker, relationship
- from sqlalchemy.dialects.postgresql import UUID
- from geoalchemy2 import Geometry
- MappedEntity = declarative_base()
- class NamedEntity(object):
- def __new__(a):
- for lang in ['ru', 'kk', 'en']:
- setattr(a, 'name_'+lang, Column(String(255)))
- #for lang in ['ru', 'kk', 'en']:
- # setattr(NamedEntity, 'name_'+lang, Column(String(255)))
- class ConcreteEntity(MappedEntity, NamedEntity):
- __tablename__ = 'entity'
- id = Column(UUID, primary_key=True)
- engine = create_engine('postgresql+psycopg2://postgres:passpass@localhost:5432/db')
- Session = sessionmaker(bind=engine)
- engine.connect()
- MappedEntity.metadata.create_all(engine)
Advertisement
Add Comment
Please, Sign In to add comment