Context
I have a PostGIS database.
If I use:
shp2pgsql -I -s 4326 -d "my_shapefile.shp" myschema.vectordata \
| psql -h localhost -U username -d my_database -v ON_ERROR_STOP=1
To inject data from a Shapefile source, I got the error:
Shapefile type: Arc
Postgis type: MULTILINESTRING[2]
SET
SET
ERROR: column not found in geometry_columns table
CONTEXT: PL/pgSQL function dropgeometrycolumn(character varying,character varying,character varying,character varying) line 34 at RAISE
SQL statement "SELECT myschema.DropGeometryColumn('',$1,$2,$3)"
PL/pgSQL function dropgeometrycolumn(character varying,character varying,character varying) line 5 at SQL statement
If I remove the -d flag, it goes well.
So I guess that, as stated in the documentation;
-d Drops the database table before creating a new table with the data in the Shape file.
it will drop the database table without checking if it exists before. So in the case tables exist, it goes well, if not, it fails as stated before.
Question
How could I make it equivalent to somehow a drop "IF EXISTS" sql statement when dropping the database table prior to injecting new data from a Shapefile?
Informations;
"PostgreSQL 10.12 (Ubuntu 10.12-0ubuntu0.18.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, 64-bit"
"2.4 USE_GEOS=1 USE_PROJ=1 USE_STATS=1"
-pflag prior to the-ddoesn't change the situation. – swiss_knight Mar 13 '20 at 15:35ogr2ogrorshp2pgsql: "The pgsql2shp and shp2pgsql are usually the best tools for converting back and forth between PostGIS and ESRI for 2 main reasons.". I'm still having some same issue while usingogr2ogr; it cannot find the postgis installation because it was set in an other schema. I don't know how to make the tool aware of that? – swiss_knight Apr 02 '20 at 16:31