Advertisement
Guest User

Untitled

a guest
May 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. import MySQLdb
  2. from config import Config
  3.  
  4. f = file('pymmo.cfg')
  5. cfg = Config(f)
  6. sqlHost = cfg.sqlHost
  7. sqlUser = cfg.sqlUser
  8. sqlPass = cfg.sqlPass
  9. dataB = cfg.dataB
  10.  
  11. conn = MySQLdb.connect(host = sqlHost,
  12.                        user = sqlUser,
  13.                       passwd = sqlPass,
  14.                       db = dataB)
  15. cursor = conn.cursor()
  16.  
  17. class Admin_Com():
  18.     def __init__(self):
  19.         pass
  20.        
  21.     def __md5Hash(string):
  22.         md5 = MD5.new()
  23.         md5.update(string)
  24.         md5.update(md5.digest())
  25.         return md5
  26.  
  27.     def md5Hash_hex(string):
  28.         return __md5Hash(string).hexdigest()
  29.        
  30.     def newUser(passWord, userName):
  31.         passWord = md5Hash_hex(passWord)
  32.  
  33.         newUserCommand = 'INSERT into authentication(userName,hash) VALUES(' + "'" + userName +"'" + ',' + "'" + passWord + "'" + ")"
  34.         #cursor.execute(newUserCommand)
  35.  
  36.     def delUser(userName):
  37.         deleteUserCommand = "DELETE from authentication WHERE userName = " + "'" + userName + "'"
  38.         #cursor.execute(deleteUserCommand)
  39.  
  40.     def changePass(userName, passWord):    
  41.         passWord = md5Hash_hex(passWord)
  42.    
  43.         changePassCommand = "UPDATE authentication set hash = " + "'" + passWord + "'" + " where userName = " + "'" + userName + "'"
  44.         #cursor.execute(changePassCommand)
  45.        
  46.        
  47. if __name__ == "__main__":
  48.     commands = Admin_Com()
  49.     userName = raw_input("Enter test name: ")
  50.     commands.newUser(userName)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement