[Python] Not enough arguments for format string error when inserting list into database SQL...

Discussão em 'Python' iniciado por Stack, Julho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to insert a list into separate columns of a database

    print inserter
    params = ['%s' for item in inserter]
    sql_query = 'INSERT INTO tablename (column1, column2, column3, column4, column5, column6, column7) VALUES (%s,%s,%s,%s,%s,%s,%s);' % ','.join(params)
    cursor.execute(sql_query)
    db.commit


    But I keep getting the error:


    not enough arguments for format string
    ​

    Does anyone know what I am doing wrong?

    Continue reading...

Compartilhe esta Página