Last active
March 30, 2023 11:40
-
-
Save KarimullinArthur/75bbd88ba802fcd021b6e1757481dce4 to your computer and use it in GitHub Desktop.
Ригистрация, учусь работать с БД
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Я же написал, что просто учусь работать с бд, да это и было-то когда.