error "illegal option --t" occus when import OSM map into postgis [windows environment] - postgresql

I want to import OSM map into postgis, so used the following command in windows cmd console:
osm2pgsql -U postgres -d osm -hstore -s _S ./default.style ./xxxx.osm
But "illegal option --t" error occus:
osm2pgsql illegal option --t
Usage error.
I don't know what's the meaning of "illegal option --t" and don't know how to handle it.
I've looked at several articles but haven't find any answer.
thanks.
p.s I've installed postgis 2.1.7 and postgresql 9.4 and hstore.

There are at least 2 mistakes in your command -hstore instead of --hstore and _S instead of -S .
So:
osm2pgsql -U postgres -d osm --hstore -s -S ./default.style ./xxxx.osm

Related

Issue with pg_restore

I have installed PostgresSQL version 12.3 for MAC OS Catalina 10.15.4. I am trying to restore the database dvdrental from https://www.postgresqltutorial.com/postgresql-sample-database/. I unzipped the dvdrental.zip file. I am executing the following commands from within the bin directory:
pg_restore -U postgres -d dvdrental /Users/programmer27/Downloads/dvdrental.zip
pg_restore -U postgres -d dvdrental /Users/programmer27/Downloads/dvdrental
I am getting an error message:
-bash: pg_restore: command not found
I am not sure if pg_restore command is working, even though I see it in the bin directory.
Sorry I'm asking a basic question. I'm just very confused.

pg_restore not working for .dump file

I'm trying to restore a database to a new environment and pg_dump/pg_restore seems like the best way for me to do that.
I've run the pg_dump command with the following code which has produced my dump file:
pg_dump -v -Fc --host=test.postgres.database.azure.com --port=5432 --username=test#test --dbname=test > test.dump
However when I run pg_restore it is not able to restore the database. I have run into two separate errors when trying two separate commands. The first error
occurs when i use the following command
pg_restore -h test.postgres.database.azure.com -p 5432 -U test#test -C test.dump
and the second
occurs upon using this command
pg_restore -h test.postgres.database.azure.com -p 5432 -U test#test -C -Fc test.dump
I really don't understand what is going wrong here. All other answers I have found that get these same errors were encountered when people tried to restore plain text files but that's not what I'm attempting to do here. Any help would be greatly appreciated.

Creating and preparing database postgres "no such file or directory"

During preparing database according to How to import OpenStreetMap data into PostgreSQL i always get error message C:/Program: No such file or directory after writing psql -U postgres -d gis -f PATH_TO_POSTGRES/share/contrib/postgis-1.5/postgis.sql In my case path looks like : C:\Program Files\PostgreSQL\9.3\share\contrib\postgis-2.1\postgis.sql
Thank you for help or advices
psql -U postgres -d gis
-f "C:\Program Files\PostgreSQL\9.3\share\contrib\postgis-2.1\postgis.sql"
Here Program Files is separated with space so you need to add double quote around the path.

Generate ER diagram from postgresql database [SchemaSpy]

Anyone use this tool? I wanted to generate a ER diagram from my database. I run SchemaSpy like this:
java -jar schemaSpy_5.0.0.jar -t pgsql -db mydb -host localhost -dp /home/katie/downloads/postgresql-8.0-312.jdbc3.jar -noschema -u postgres -o .
and then, I got errors:
Using database properties:
[schemaSpy_5.0.0.
jar]/net/sourceforge/schemaspy/dbTypes/pgsql.properties
Gathering schema details..........................................................java.sql.SQLException: ERROR: function information_schema._pg_keypositions() does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:221)
at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getImportedExportedKeys(AbstractJdbc2DatabaseMetaData.java:3237)
at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getImportedKeys(AbstractJdbc2DatabaseMetaData.java:3533)
at net.sourceforge.schemaspy.model.Table.connectForeignKeys(Table.java:106)
at net.sourceforge.schemaspy.model.Database.connectTables(Database.java:984)
at net.sourceforge.schemaspy.model.Database.<init>(Database.java:83)
at net.sourceforge.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:211)
at net.sourceforge.schemaspy.Main.main(Main.java:42)
I use PostgreSQL 9.1 on Xubuntu 12.04.
Issues were resolved by:
Using a PgJDBC contemporary to the PostgreSQL 9.1 database install, instead of trying to use PgJDBC 8.0; and
Using the JDBC3 driver, as SchemaSpy didn't seem to like the JDBC4 driver.
java -jar F:/schema/schemaSpy_5.0.0.jar -t postgresql -db dhis2ccem1 -host localhost -port 5432 -s public -u postgres -p root -dp F:/schema/postgresql-9.0-801.jdbc4.jar -o output

importing osm file into a postgres/postgis database

Im using the tool osm2pgsql to import an osm file into a postgres database using phppgadmin as the administrative tool. i have only downloaded a small town from osm in xml format and im having trouble importing it using the terminal on mac. Im a bit of a noob at this so any help would be greatly appreciated. Ive looked at several articles but none provide the clarity i need in order to fulfill my needs.
Thanks
im getting this error could be something small not sure..
Using projection SRS 900913 (Spherical Mercator)
Setting up table: planet_osm_point
NOTICE: table "planet_osm_point" does not exist, skipping
NOTICE: table "planet_osm_point_tmp" does not exist, skipping
SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );
failed: ERROR: function addgeometrycolumn(unknown, unknown, integer, unknown, integer) does not exist
LINE 1: SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, ...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
You need to install the postgis extensions into your postgres database. Assuming that you have postgis installed on your machine you need to do something like:
psql <database> < /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
The exact path to postgis.sql will depend on the distribution you are using and how it has packaged postgis. You may also want/need to install the spatial reference systems table with a command like this:
psql <database> < /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
This is an example command:
osm2pgsql -c -d your_country -U postgres -W -H localhost -P 5432 -s -k -x -p osm -S default.style ..\your_country.osm.bz2
Here are some useful weblinks:
http://wiki.openstreetmap.org/wiki/Osm2pgsql
http://www.gis.hsr.ch/wiki/Osm2pgsql
-S.