首頁 >後端開發 >php教程 >导入用户到Discuz论坛

导入用户到Discuz论坛

PHP中文网
PHP中文网原創
2016-06-13 11:26:161037瀏覽

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)


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn