M
M
maks_petrov92021-09-19 10:59:13
Python
maks_petrov9, 2021-09-19 10:59:13

Can't save text to sqlite3 database via discord.py, what should I do?

So I started writing a discord bot (in python), connected it to sqlite3, and wrote a little code so that the user could provide some information about himself. The code works, but only if you specify just numbers there, and if you write in letters, then nothing happens. There are no errors in the console, I do not know what to do. Thanks in advance. Here is the code:

@Bot.command()
async def yo(ctx, *, text = None):
  if text is None:
    await ctx.send('Напишите пару слов о себе!')
  else:
    cursor.execute("UPDATE users SET aboutme = {} WHERE id = {}".format(text, ctx.author.id))
    connection.commit()
    await ctx.send(f'Готово!')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2021-09-19
@maks_petrov9

https://qna.habr.com/q/1028400

A
alekssamos, 2021-09-19
@alekssamos

SQL has its own formatting/substitution functions, not .format!
Do you include question marks there? instead of {}, and pass the variables as the arguments following the request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question