[gdal-dev] GPKG to PG single transaction, different schemas

Matteo Ghetta matteo.ghetta at gmail.com
Wed May 15 00:31:18 PDT 2024


Hi Even,

thanks for the reply!

I downloaded the 
https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/samples/ogr2vrt.py 
file and used like:

python3 ogr2vrt.py export_db.gpkg export_db.vrt first_layer second_layer

but I get the following error:

Traceback (most recent call last):
   File "/home/matteo/import_export/ogr2vrt.py", line 353, in <module>
     sys.exit(main(sys.argv))
              ^^^^^^^^^^^^^^
   File "/home/matteo/import_export/ogr2vrt.py", line 329, in main
     if src_fd.GetComment():
        ^^^^^^^^^^^^^^^^^
AttributeError: 'FieldDefn' object has no attribute 'GetComment'

while with the ogr2vrt file in 
/usr/lib/python3/dist-packages/osgeo_utils/samples/ogr2vrt.py it works 
nice! Not sure what I'm missing.

So basically the content of the resulting file that I've adapted is:

....
<OGRVRTLayer name="first_schema.first_layer">
     <SrcDataSource relativeToVRT="1" 
shared="1">export_db.gpkg</SrcDataSource>
     <SrcLayer>first_layer</SrcLayer>
....
<OGRVRTLayer name="second_schema.second_layer ">
     <SrcDataSource relativeToVRT="1" 
shared="1">export_db.gpkg</SrcDataSource>
     <SrcLayer>second_layer </SrcLayer>
...

and with ogr2ogr it's working nice in a single transaction!

The vrt file generation is also adding layer metadata, is there a way to 
avoid them or should I remove them manually after the file creation?

Cheers and thanks again!

Matteo


More information about the gdal-dev mailing list