from tools import *
import pandas as pd
import numpy as np

def modifyPasseord(name,namespace):
    #conn_db_11=create_engine('mysql://qa:{}@172.17.5.11:30077'.format('qatest'))
    #conn_db_11=create_engine('mysql://qa:{}@172.17.5.48:31393'.format('qatest'))
    conn_db_11=mysql_universal(namespace)
    import hashlib
    pw=b'123456qwe'
    get_salt="""
    select salt from stms.t_sys_user where  account='{name}'
    """.format(name=name)
    salt_df=pd.read_sql(get_salt,con=conn_db_11)
    temp=salt_df.to_dict(orient='records')
    if not temp:
        print('[{name}] is not exist'.format(name=name))
        return 0
    salt=temp[0]['salt'].encode()
    #salt=b'UwKESe3cvf703Z30' #t_sys_user.salt
    tt=hashlib.sha512(pw+salt).hexdigest()
    sql="""
    update stms.t_sys_user set password='{password}' where account='{name}'
    """.format(password=tt,name=name)
    try:
        pd.read_sql(sql,con=conn_db_11)
    except:
        print("this is update")

if __name__ == '__main__':
    modifyPasseord('haiyuan.wen','vcc2')