Answer the question
In order to leave comments, you need to log in
Trouble with Telebot Python Sqlite3?
I want to make sure that a new one is added exactly the same to the previous Login + Name entry, but on a different line. When I write /add and write for example "hello" or "fhwefuiwefgiw 322 fsde" (it doesn't matter, only the first word of the sentence is selected), then the first word is stored in the database - 0.
Code:
def support_reg(message):
word = str( message.text)
name_for_table = (word.split()[0])
db = sqlite3.connect('db_for_freelance.db')
sql = db.cursor()
sql.execute("""CREATE TABLE IF NOT EXISTS users (
login TEXT,
name TEXT,
cash INT,
comment TEXT
)""")
db.commit()
sql.execute(f'UPDATE users SET name = name + \n? WHERE login = ?', (name_for_table, message.from_user.id))
db.commit()
check_name = sql.execute(f"SELECT name from users WHERE login = '{message.from_user.id}'").fetchone()[0]
print(check_name)
bot.send_message(message.chat.id, f"Support nickname: {check_name}")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question