예제 #1
0
def db_delete_user_no_prefix(username):

    mysql_handle = MysqlDB()
    ids = mysql_handle.select('ppc_tenants', 'id', name=username)
    if len(ids) != 0:
        account_id = int(ids[0][0])
        mysql_handle.delete('ppc_user_group', user_id=account_id)
        mysql_handle.delete('ppc_users', username=username)
        mysql_handle.delete('ppc_tenants', name=username)
    else:
        print "#############################################"
        print "###   no such account, pls check out!     ###"
        print "#############################################"
예제 #2
0
def db_add_user_no_prefix(username, password):

    mysql_handle = MysqlDB()
    mysql_handle.insert('ppc_tenants', name=username, license_verify=0)
    ids = mysql_handle.select('ppc_tenants', 'id', name=username)
    if len(ids) != 0:
        account_id = int(ids[0][0])
        password = '******'+password
        import hashlib
        m = hashlib.md5()
        m.update(password)
        password = m.hexdigest()
        import time
        time_string = time.strftime('%Y-%m-%d %H:%M:%S')

        mysql_handle.insert('ppc_users', id=account_id, tenant_id=account_id, username=username,
                         password=password, salt='salt', phone='11133333333', email='*****@*****.**',
                         verify_code='verify_code', create_time=time_string
                         )
        mysql_handle.insert('ppc_user_group', user_id=account_id, group_id='3')
    else:
        print "#############################################"
        print "###        create account fail            ###"
        print "#############################################"