M
M
mihailos2020-11-24 19:03:08
Python
mihailos, 2020-11-24 19:03:08

How not to stop the database?

There is a code

@bot.message_handler(commands=['start'])
def welc(message):
    idUser = message.from_user.id
    userName = message.from_user.first_name
    bot.send_message(message.chat.id, "Что хотите узнать?")
    cur.execute("INSERT INTO users(username, id_tele) VALUES(?, ?)", (userName, idUser))
    cur.close()
    conn.commit()

After processing /start once, crashes a second time: sqlite3.ProgrammingError: Cannot operate on a closed cursor.
How is it possible to fix this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MaxKozlov, 2020-11-24
@mihailos

not close the cursor?

M
mihailos, 2020-11-24
@mihailos

EVERYTHING, I DECIDED
I just declare in the cur function in a new way and it works

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question