Skip to content

Instantly share code, notes, and snippets.

@KarimullinArthur
Last active March 30, 2023 11:40
Show Gist options
  • Save KarimullinArthur/75bbd88ba802fcd021b6e1757481dce4 to your computer and use it in GitHub Desktop.
Save KarimullinArthur/75bbd88ba802fcd021b6e1757481dce4 to your computer and use it in GitHub Desktop.
Ригистрация, учусь работать с БД
import sqlite3
conn = sqlite3.connect('date.db')
cur = conn.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
password TEXT);""")
conn.commit()
def rigistration():
global conn
global cur
login = input("Input your login\n> ")
check = cur.execute('SELECT * FROM users WHERE name=?', (login, ))
if check.fetchone() is None:
password = input("Input your password\n> ")
passwordCheck = input("Input password again\n> ")
if password == passwordCheck:
inp = (login,password)
cur.execute("INSERT INTO users(name,password) VALUES(?,?)",inp)
conn.commit()
print("All right, you are registered!")
else:
print("Oops,you entered two different passwords. Please try again.")
else:
print('Login busy')
rigistration()
@KarimullinArthur
Copy link
Author

Я же написал, что просто учусь работать с бд, да это и было-то когда.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment