[gdal-dev] Export PG to GPKG with foreign keys
Matteo Ghetta
matteo.ghetta at gmail.com
Sun Apr 21 22:59:29 PDT 2024
Hi Even,
thanks for the reply! I had this feeling, but now I'm sure
Cheers and thanks
Matteo
On 4/19/24 11:32, Even Rouault wrote:
>
> Le 19/04/2024 à 10:25, Matteo Ghetta via gdal-dev a écrit :
>> Hi all,
>>
>> I'm trying to export a PG table with several foreign keys to a
>> geopackage.
>>
>> What I tried so far are the native QGIS export and the QGIS Processing
>> algorithm "Package layer" with the "Export related layers
>> following..." option activated.
>>
>> I'm checking ogr2ogr but I cannot see any option to include the export
>> of the foreign keys. Is this option available in order to have a
>> geopackage with the original table with all the other related tables?
>
> In short, no
>
> It might be possible to use the relationship API of
> https://gdal.org/api/gdaldataset_cpp.html#_CPPv4NK11GDALDataset20GetRelationshipNamesE12CSLConstList to build something around it. But adding foreign key constraint themselves would be tricky as it requires to rewrite the CREATE TABLE.
>
> Even
>
>
More information about the gdal-dev
mailing list