Что не так с этим кодом?
Ошибка:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\alextimson\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\alextimson\Desktop\bot\bot.py", line 29, in on_ready
cursor.execute(f"INSERT INTO users VALUES ('{member}', {member.id}, 0, 0, 1, 'хрущёвка')")
sqlite3.OperationalError: table users has 2 columns but 6 values were supplied
Код:
#database
connection = sqlite3.connect('ussg.db')
cursor = connection.cursor()
##
##
# database
@client.event
async def on_ready():
cursor.execute("""CREATE TABLE IF NOT EXISTS users (
name TEXT,
id INT
cash BIGINT
rep INT
lvl INT
home TEXT
)""")
for guild in client.guilds:
for member in guild.members:
if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
cursor.execute(f"INSERT INTO users VALUES ('{member}', {member.id}, 0, 0, 1, 'хрущёвка')")
else:
pass
connection.commit()
print('Бот запущен')
@client.event
async def om_member_join(member):
if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
cursor.execute(f"INSERT INTO users VALUES ('{member}', {member.id}, 0, 0, 1, 'хрущёвка')")
connection.commit()
else:
pass