M
M
MArtyCx2020-06-09 13:13:50
Python
MArtyCx, 2020-06-09 13:13:50

Why did the sqlite3: near "Dim": syntax error appear?

I made a bot discord and this error popped up, the bot does not have people with the nickname "Dim",
there are no such variables and there are no other words related to this, I climbed a lot of forums but there I did not find a solution to my problem.

async def on_ready():

        cursor.execute("""CREATE TABLE IF NOT EXISTS stats(
    name TEXT,
    id INT,
    warn INT,
    rep INT
    )""")
        connection.commit()

      for guild in client.guilds:
        for member in guild.members:
          if cursor.execute(f"SELECT id FROM stats WHERE id = {member.id}").fetchone() is None:
            try:
              cursor.execute(f"INSERT INTO stats VALUES ('{member}', {member.id}, 0, 0)") #Кричит на эту строку
              connection.commit()
            except Exception:
              print('Ошибка')
              print(sys.exc_info()[1])
          else:
                  pass

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-06-09
@MArtyCx

Comment out the line:

cursor.execute(f"INSERT INTO stats VALUES ('{member}', {member.id}, 0, 0)")

add after it:
print(f"INSERT INTO stats VALUES ('{member}', {member.id}, 0, 0)")

and see the output in the console.
Or you can try like this:
cursor.execute("INSERT INTO stats VALUES (?,?,?,?)",(member,member.id,0,0))

G
galaxy, 2020-06-09
@galaxy

print(f"INSERT INTO stats VALUES ('{member}', {member.id}, 0, 0)")

And everything, I think, will become clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question