Example #1
0
"""


if __name__ == "__main__":
    # model = Model()
    # model.select(select_param=["id", "name", "gender"], where_param={"name = ": "jack", "gender = ": "M"})
    # model.order_by(["name desc", "gender desc"])
    # model.limit(1, 4)
    # result = model.execute()
    # print result
    # model.insert(result)

    # 配置
    print finance_dict
    # 迁移数据库
    model = DBConnection(**finance_dict)
    # 要迁移的数据库表 CpcFinanceDetail
    model.table_name = "CpcFinanceDetail"

    model_v2 = DBConnection(**finance_dict)
    # 迁移的数据迁移到 CpcFinanceDetail1
    model_v2.table_name = "CpcFinanceDetail1"

    # 从线下库中找到上次同步的id
    model_v2.select(select_param=["max(id) as max_id"])
    mid = model_v2.execute()
    max_id = mid[0]["max_id"]
    if max_id is None:
        max_id = 0
    # 同步操作
    status = True
Example #2
0
"""


if __name__ == "__main__":
    # model = Model()
    # model.select(select_param=["id", "name", "gender"], where_param={"name = ": "jack", "gender = ": "M"})
    # model.order_by(["name desc", "gender desc"])
    # model.limit(1, 4)
    # result = model.execute()
    # print result
    # model.insert(result)

    # 配置
    print migrate_db_dict, ads_offline_db_dict
    # 迁移数据库
    model = DBConnection(**migrate_db_dict)
    # model.table_name = "UnionKeyWord"

    # 广告线下数据库
    model_v2 = DBConnection(**ads_offline_db_dict)
    # model_v2.table_name = "UnionKeyWord"

    # 显示所有数据表
    result = model.show_tables()
    print "检测数据库中表......."
    print model.kwargs["host"] + " 数据库中有如下表:"
    for table in result:
        print table

    """
    # 同步两个库中的表结构