I am trying to insert data into users table:
cursor.execute("""CREATE TABLE IF NOT EXISTS users (
name TEXT NOT NULL,
id BIGINT NOT NULL,
xp INT NOT NULL
)""")
for guild in bot.guilds:
for member in guild.members:
if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}") is None:
if member.id not in bots:
cursor.execute("INSERT INTO users (name, id, xp) VALUES ('{}', {}, {});".format(member, member.id, 0))
connect.commit()
connect.close()
But I keep getting the error:
File "C:\Users\belog\hat_dispenser\main.py", line 58, in on_ready
cursor.execute("INSERT INTO users (name, id, xp) VALUES ('{}', {}, {})".format(member, member.id, 0))
psycopg2.errors.NumericValueOutOfRange: integer out of range
I tried to give the column "id" data types such as BIGINT, INT, BIGSERIAL, SERIAL. But I still get an "integer out of range" error. How to fix it?
xp
– Copenhagenprint
the value for the variablemember.id
or look in the Postgres log to see what is being passed in. Best bet it is something that is larger then9223372036854775807
. – Medianint
andserial
. You would needbigint
/bigserial
. Start with the premise that the error is telling you the truth and work backwards from there. Me I start with the Postgres log as that shows you what is actually hitting the database and has the full error message. – Median