Код:
import sqlite3
db = sqlite3.connect('server.db')
sql = db.cursor()
sql.execute("""CREATE TABLE IF NOT EXISTS users (
login TEXT,
password TEXT,
cash BIGINT
)""")
db.commit()
user_login = input('Login: ')
user_password = input('Password: ')
sql.execute("SELECT login FROM users")
if sql.fetchone() is None:
sql.execute(f"INSERT INTO users VALUES (?, ?, ?)", (user_login, user_password, 0))
db.commit()
else:
print('No!')
Ошибка:
Traceback (most recent call last):
File "C:\Users\1\Desktop\learn\learn_sqlite\main.py", line 19, in <module>
sql.execute(f"INSERT INTO users VALUES (?, ?, ?)", (user_login, user_password, 0))
sqlite3.OperationalError: table users has 4 columns but 3 values were supplied
PS C:\Users\1\Desktop\learn\learn_sqlite>