Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import MySQLdb as mdb
  2. import sys
  3.  
  4. name = ""
  5. password = ""
  6.  
  7. conn = mdb.connect('localhost', 'vlad', 'enma1991x', 'test')
  8. cursor = conn.cursor()
  9.  
  10. print "Please enter your desired username: "
  11. name = raw_input("> ")
  12.  
  13. print "Please enter your desired password: "
  14. password = raw_input("> ")
  15.  
  16. try:
  17. cursor.execute("CREATE TABLE IF NOT EXISTS \
  18. Users(Id INT PRIMARY KEY AUTO_INCREMENT, Username VARCHAR(25), Password VARCHAR(25))")
  19. cursor.execute("INSERT INTO Users(Username) VALUES('%s')", [name])
  20. cursor.execute("INSERT INTO Users(Password) VALUES('%s')", [password])
  21. except mdb.Error, e:
  22. print "Error %d : %s" % (e.args[0], e.args[1])
  23. sys.exit(1)
  24.  
  25. conn.commit()
  26.  
  27. cursor.close()
  28. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement