[Python] psycopg2.extras.execute_values to insert multiple rows for geometry data

Discussão em 'Python' iniciado por Stack, Dezembro 18, 2024.

  1. Stack

    Stack Membro Participativo

    This is my insert query

    sql = "INSERT INTO sightings (run_id, geometry, properties)
    VALUES(%s, ST_MakePoint(%s, %s), %s);"


    1) run_id is an internal uuid

    2) geometry - this is geopoint object

    3) properties is a JSON object

    On running psycopg2.extras.execute_values(cur, sql, listOfTuples) I get an error that says:


    the query contains more than one '%s' placeholder'
    ​

    I realize my mistake around this, but how can I get around it. Is there a way the template parameter can be of any help.

    Continue reading...

Compartilhe esta Página