I am trying to import GeoJSON file with Python to my PostgreSQL db.
Here is full code:
with open('C:/xampp/htdocs/app/data/'+a) as file:
gj=geojson.load(file)
for feature in gj['features']:
geom=feature['geometry']
kc_broj=feature['properties']['BROJ_KC']
ko_broj=feature['properties']['KO']
ko_naziv=feature['properties']['K.O.']
jls='RUGVICA1'
id=str(ko_broj)+'_'+kc_broj
cur.execute('INSERT INTO dkp (id,geom,ko_broj,kc_broj,ko_naziv,jls) VALUES (%s, ST_GeomFromText(ST_AsText(ST_GeomFromGeoJSON(%s))), %s, %s, %s, %s)', (id, geom ,ko_broj, kc_broj, ko_naziv, jls,))
And I get error :
psycopg2.ProgrammingError: can't adapt type 'Polygon'
Does anyone know how to fix this?