[Python] psycopg2.errors.NumericValueOutOfRange: integer out of range

Discussão em 'Python' iniciado por Stack, Janeiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página