1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How do I insert this list into a postgresql array

Discussão em 'Python' iniciado por Stack, Setembro 25, 2021.

  1. Stack

    Stack Membro Participativo

    `def copy_Stones(ipt, lhailstones):
    iptstr = str(ipt)
    iptuple = (iptstr)
    cur.execute("INSERT INTO Hailstones(ID) VALUES({})".format(ipt))
    #the above query works in isolation

    res = str(lhailstones)[1:-1]
    cur.execute("INSERT INTO Hailstones(Stones) VALUES({})".format(res))

    #for this query I am getting the following error: psycopg2.errors.SyntaxError: INSERT
    has more expressions than target columns LINE 1: INSERT INTO Hailstones(Stones) VALUES(4, 2, 1)`


    I don't understand how to insert this list into this array. If it's an array why can't it accept the list?

    Continue reading...

Compartilhe esta Página