python类来自两个来源

时间:2017-11-14 13:31:38

标签: python sql-server postgresql class sqlalchemy

我正在尝试在会计软件和内部软件之间同步数据。 会计软件在MSSQL上运行,我们的软件在PGSQL

上运行

是否可以创建一个包含两个数据源的单个类,可能还有两个不同的结构和一个映射方法?或者使用映射方法创建两个不同的类更容易吗?

一堂课:

class test(Base):
    __tablename__ = 'test'

    def __init__(self, type='MSSQL'):
        self.type = type
        self.__tablename__ = __tablename__

    @classmethod
    def DBMSSQL(cls):
        return cls('MSSQL')

    @classmethod
    def DBPGSQL(cls):
        return cls('PGSQL')

如何映射两种类型之间的字段以及如何更改使用的引擎?

或者有两个班级:

class testMSSQL(Base):
    __tablename__ = 'test'
    __table_args__ = {"schema": "dbo"}

    to_testPGSQL():
        pass

class testPGSQL(Base):
    __tablename__ = 'testPG'

    to_testMSSQL():
        pass

由于

0 个答案:

没有答案
相关问题