Answer the question
In order to leave comments, you need to log in
How to write values to PostgreSQL database?
My discord.py bot had a sqlite3 db due to heroku constantly invalidating the db after the bot is reloaded. Decided to switch to postgresql. When I tried to write data to a table, as I did on sqlite, I got syntax errors .. or an error where the data was perceived as the name of the table.
This is part of the code using sqlite3.
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
for guild in client.guilds:
for member in guild.members:
cursor.execute(f"SELECT id FROM users WHERE id = {member.id}")
if cursor.fetchone() is None:
pass # Здесь должна быть запись member, member.id, cash(0), rep(0), lvl(1)
else:
pass
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