I have a feature class of 20k records. trying to import it into postgis using arcpy and psycogp2. I have a pretty basic script
cur.execute('''drop table if exists developed_lands.daysemtric_test''')
cur.execute('''CREATE TABLE developed_lands.daysemtric_test
(pid serial primary key,
pop_dns float,
shape geometry);''')
with arcpy.da.SearchCursor(shp, ["POP_DNS","SHAPE@WKT"]) as cur2:
for row in cur2:
sql = "insert into developed_lands.daysemtric_test(pop_dns,shape)values(%s,ST_GeomFromText(%s)"
cur.execute(sql,(row[0],row[1]))
x+=1
print x
conn.commit()
error:
Traceback (most recent call last):
File "C:\Users\rizagha\Desktop\module1.py", line 16, in <module>
cur.execute(sql,(row[0],row[1]))
InternalError: geometry requires more points
HINT: "...6391.65285167098 737288.47085659206)," <-- parse error at position 13049795 within geometry
^
This script works because If I skip the first feature it inserts the records up to row 2,000 then throws the same error. I put the function st_makevalid() around ST_GeomFromText(%s) and it did nothing to help. running repair geometry on the feature class now, but that usually takes hours...
the first row where the error is happening, the geometry is extremely complex. is it possible the WkT is too long?
UPDATE
repair geometry finished and I reran the script and I got the same error