5

I'm attempting to load a file gdb to an alternate postgresql database schema. The process works OK with the following but uploads to the public schema.

ogr2ogr -f "PostgreSQL" PG:"host=localhost port=5432 dbname=GIS user=postgres password=xxxxxx" "C:\test.gdb

Can anyone assist?

artwork21
35.2k8 gold badges69 silver badges135 bronze badges
asked Apr 3, 2017 at 3:18

2 Answers 2

4

You can add into your connection string the option ACTIVE_SCHEMA=your_schema

ogr2ogr -f "PostgreSQL" PG:"host=localhost port=5432 dbname=GIS user=postgres password=xxxxxx ACTIVE_SCHEMA=your_schema" "C:\test.gdb

All other options can be found in the driver documentation: http://www.gdal.org/drv_pg.html

answered Apr 3, 2017 at 6:06
3

Reading the manual page http://www.gdal.org/drv_pg.html makes me think that you must add a layer creation option "schema" or dataset open option "active_schema".

Layer creation options

SCHEMA: Set name of schema for new table. Using the same layer name in different schemas is supported, but not in the public schema and others. Note that using the -overwrite option of ogr2ogr and -lco SCHEMA= option at the same time will not work, as the ogr2ogr utility will not understand that the existing layer must be destroyed in the specified schema. Use the -nln option of ogr2ogr instead, or better the active_schema connection string. See below example.

Dataset open options

ACTIVE_SCHEMA=string: Active schema

I would have a try with these commands:

ogr2ogr -f "PostgreSQL" PG:"host=localhost port=5432 dbname=GIS user=postgres password=xxxxxx" "C:\test.gdb -lco schema=my_schema
ogr2ogr -f "PostgreSQL" PG:"host=localhost port=5432 dbname=GIS user=postgres password=xxxxxx" "C:\test.gdb -doo ACTIVE_SCHEMA=my_schema
answered Apr 3, 2017 at 6:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.