Rectangle 27 0

if multi:
    mygeom = "ST_Multi(ST_GeomFromGml(%s))"
else:
    mygeom = "ST_GeomFromGml(%s)"

self.cursor.execute( """INSERT INTO {}.parcel (
    id,geometry) VALUES (%s, {})""" .format(self.config.schema, mygeom) , (self.id, self.geometry) )

I inserted the schema and function with a string format method. I also inserted self.geometry in a safe way.

python - Pass dynamic database function to psycopg2 cursor.execute(sta...

python postgis psycopg2
Rectangle 27 0

if multi:
    mygeom = "ST_Multi(ST_GeomFromGml(%s))"
else:
    mygeom = "ST_GeomFromGml(%s)"

self.cursor.execute( """INSERT INTO {}.parcel (
    id,geometry) VALUES (%s, {})""" .format(self.config.schema, mygeom) , (self.id, self.geometry) )

I inserted the schema and function with a string format method. I also inserted self.geometry in a safe way.

python - Pass dynamic database function to psycopg2 cursor.execute(sta...

python postgis psycopg2