Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

PostgreSQL Connector

Henning Bredel edited this page Aug 14, 2014 · 9 revisions

Quick start

Loading data from a database is simply done by

  1. create a resource with the connection URL
  2. setting access credentials
  3. work with the IlwisObject as usual

In a few lines of code this can look like this

QUrl connectionString("postgresql://localhost:5432/ilwis-pg-test/tl_2010_us_rails");
Resource rails(connectionString,itCOVERAGE);
rails.addProperty("pg.password", "postgres");
rails.addProperty("pg.user", "postgres");

IFeatureCoverage fcoverage;
fcoverage.prepare(rails);

fcoverage->connectTo(makeOutputPath("rails.shp"), "ESRI Shapefile", "gdal", IlwisObject::cmOUTPUT);
fcoverage->store();

The above code will load data from the database and store it back as ESRI Shape file. The data comes from the tl_2010_us_rails table in database ilwis-pg-test which is accessible from localhost and standard PostgreSQL port. As usual a resource with corresponding IlwisType is prepared with the user credentials set needed to access the database.

Details

The whole way of preparing and loading the data is like with other connectors. For PostgreSQL data sources one has to use the connection link as follows:

postgresql://<host>:<port>/<database>/[<schema>]/<tablename>

tbd

Clone this wiki locally