import torndb
db_info1 = dict(
host = "127.0.0.1:3306",
data = "data_test",
user = "root",
password = "password")
db_info2 = dict(
host = "127.0.0.1:3306",
data = "dz_bbs",
user = "root",
password = "password.c0m")
db1 = torndb.Connection(
host = db_info1.get('host'),
database = db_info1.get('data'),
user = db_info1.get('user'),
password = db_info1.get('password')
)
db2 = torndb.Connection(
host = db_info2.get('host'),
database = db_info2.get('data'),
user = db_info2.get('user'),
password = db_info2.get('password')
)
sql = "select username, password from temp_users order by id;"
ret = db1.query(sql)
salt = '123645'
for item in ret:
username = item.get('username')
password = item.get('password')
sql = "insert into pre_ucenter_members (username,password,salt) values('%s', md5(concat(md5('%s'),'%s')),'%s');" % (username, password, salt, salt)
db2.execute(sql)
登入後複製