<div dir="ltr"><div><div><div><div><div>Hi <br><br></div>I'm trying to copy some features from one postgis table to another postgis table:<br><br>dstLayer.StartTransaction()<br><br>srcFeature = srcLayer.GetNextFeature()<br>while srcFeature is not None:<br>    srcLayerDefn = srcLayer.GetLayerDefn()<br><br>    dstLayerDefn = dstLayer.GetLayerDefn()<br>    dstFeature = ogr.Feature(dstLayerDefn)<br>    dstFeature.SetFID(-1)<br><br>    for i in range(0, dstLayerDefn.GetFieldCount()):<br>        attrName = dstLayerDefn.GetFieldDefn(i).GetNameRef()<br><br>        # ATTRIBUTES<br>        try:<br>            attrVal = srcFeature.GetField(attrName)<br>            dstFeature.SetField(attrName, attrVal)<br>        except ValueError:<br>            pass<br><br>    # GEOMETRY<br>    geom = srcFeature.GetGeometryRef()<br>    dstFeature.SetGeometry(geom)<br><br>    # ADD FEATURE<br>    dstLayer.CreateFeature(dstFeature)<br><br>    srcFeature = srcLayer.GetNextFeature()<br><br>dstLayer.CommitTransaction()<br><br></div>It throws an error when trying to create the new feature:<br><br>GNM: GNMRegisterAllInternal<br>GNM: RegisterGNMFile<br>GNM: RegisterGNMdatabase<br>PG: DBName="xanadu2"<br>PG: PostgreSQL version string : 'PostgreSQL 9.5.4 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609, 64-bit'<br>PG: PostGIS version string : '2.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1'<br>GDAL: GDALOpen(PG: host=localhost dbname=xanadu2 user=stefan password=XXXXXXXXXX this=0x11e41b0) succeeds as PostgreSQL.<br>PG: Command Results Tuples = 11<br>GDAL: GDALDriver::Create(Memory,,0,0,0,Unknown,(nil))<br>PG: 11 features read on layer 'sql_statement'.<br>PG: DBName="xanadu2"<br>PG: PostgreSQL version string : 'PostgreSQL 9.5.4 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609, 64-bit'<br>PG: PostGIS version string : '2.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1'<br>GDAL: GDALOpen(PG: host=localhost dbname=xanadu2 user=stefan password=XXXXXXXXXX this=0x12db330) succeeds as PostgreSQL.<br>PG: Primary key name (FID): t_id, type : int8<br>PG: Using column 't_id' as FID for table 'nachfuehrngskrise_nachfuehrungskreis'<br>Traceback (most recent call last):<br>  File "./datenumbau.py", line 117, in <module><br>    dstLayer.CreateFeature(dstFeature)<br>  File "/usr/local/gdal_master/lib/python2.7/site-packages/osgeo/ogr.py", line 1479, in CreateFeature<br>    return _ogr.Layer_CreateFeature(self, *args)<br>RuntimeError: OGR Error: General Error<br>GDAL: GDALClose(PG: host=localhost dbname=xanadu2 user=stefan password=XXXXXXXXXX this=0x12db330)<br>GDAL: GDALClose(PG: host=localhost dbname=xanadu2 user=stefan password=XXXXXXXXXX this=0x11e41b0)<br>GDAL: In GDALDestroy - unloading GDAL shared library.<br>GDAL: Force close of  (0x136abb0) in GDALDriverManager cleanup.<br>Mem: 1 features read on layer 'sql_statement'.<br><br></div>I'm bit confused about the "general error". Does anyone has an idea? <br><br></div>regards<br></div>Stefan <br><div><div><div><br></div></div></div></div>