Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from myconnection import connect_to_mysql
- config = {
- "host": "127.0.0.1",
- "user": "root",
- "password": "",
- "database": "examdb",
- }
- uname = input("enter username: ")
- pwd = input("enter password: ")
- cnx = connect_to_mysql(config, attempts=3)
- if cnx and cnx.is_connected():
- # sql = "SELECT * FROM users where username=%s and password=%s "
- sql = "INSERT INTO users (username,password) values (%s,%s)"
- with cnx.cursor() as cursor:
- result = cursor.execute(sql, (uname, pwd))
- # rows = cursor.fetchall() # cnx.commit()
- # for row in rows:
- # print(row)
- cnx.commit()
- cnx.close()
- else:
- print("Could not connect")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement