小编iam*_*613的帖子

SQLAlchemy - AttributeError:“表”对象没有属性替换

我正在尝试从一个数据库中的表中提取架构并将其传输到另一个数据库。以下是执行此操作的函数的一部分。Table( ... )调用时会出错。

功能示例:

def transfer_data(self, from_db, to_db, tables, flush_interval=1000, table_data_filters = {}):
    if from_db is to_db or from_db == to_db:
        raise Exception("""Usage: Can't transfer tables to and from the same database!""")

    source, sengine = (from_db.new_session(), from_db.engine()) if isinstance(from_db, SessionManager) else self.__make_session(from_db)
    dest, dengine = (to_db.new_session(), to_db.engine()) if isinstance(to_db, SessionManager) else self.__make_session(to_db)
    meta = MetaData()
    with source.no_autoflush and dest.no_autoflush:
        for table_name in tables:
            print 'Processing', table_name
            print 'Pulling schema from source server'
            # ERROR OCCURS BELOW WITH CALL …
Run Code Online (Sandbox Code Playgroud)

replace sqlalchemy attributeerror unicode-escapes

2
推荐指数
1
解决办法
2万
查看次数