How to override a column name in sqlalchemy using reflection and descriptive syntax

前端 未结 3 1360
暖寄归人
暖寄归人 2020-12-30 08:40

Hello I\'m trying to port a legacy application to python with sqlalchemy.

The application\'s existing database has about 300 tables and in every table there is a col

3条回答
  •  旧巷少年郎
    2020-12-30 09:11

    You could define your Table this way:

    mymetadata = MetaData()
    Base = declarative_base(metadata=mymetadata)
    
    class Accnt(Base):
        __tablename__ = 'accnt'
    
        code = Column(String(20))
        def_ = Column(String(50))
    

提交回复
热议问题