Q&A - Question
PostgreSQL/Postgis direct connection
Question
FabD asked on May 23, 2019, keyword: Developer Kernel
I'm trying the .NET SDK (trial version). I need to create some layers taking the data from a PostgreSQL/PostGIS database.
Now I can create the layers connecting to the database through ODBC using the TGIS_LayerSqlPgisAdo class. I would like to know if there is a way to connect directly to the database without using the ODBC interface.
I've read that I can also use the OLEDB interface. In your experience, what's the best choice in terms of performance?
Thanks
Answers
Artur Redzko (TatukGIS) replied September 12, 2016
The best provider is LIBPQ. To use it with the NDK, make a .ttkls file as described :
[TatukGIS Layer]
Storage=PostGIS
Layer=name|name;schema|name;schema;catalog
Features=table/view name; if provided will replace standard features table
Dialect=POSTGRESQL
Libpq=LIBPQ connection string
ReadOnly=True|False
GeometryFieldCast=Text|Binary|EWKB|Native - default is Binary if parameter omitted
GeometryRelationships=Server|Client - default is Client if parameter omitted
GeometryColumn=name of geometry column if there are many
IndexColumn=unique ID column name for the UID (must be numeric type)
Sequence=sequence name used to retrieve unique shape uid
VacuumAnalyse=True|False
RowsetSize=number of rows to fetch in a batch from a cursor (default 0, recommended 2000)
e.g. :
[TatukGIS Layer]
Storage=PostGIS
Layer=Rivers
Dialect=POSTGRESQL
Libpq=host=db port=5432 dbname=gis user=p password=u client_encoding=WIN1250
then copy libpq dll-s from postgres installation into your application .exe directory and open the layer with the .ttkls file in the viewer.
FabD replied September 13, 2016
Thank you very much, I've tried with LIBPQ and it works.
Only a little clarification: copying libpq.dll is not enough because it has some dependencies. You must also copy all dependencies (some other DLLs that one can found using a Dependency Walker)
Artur Redzko (TatukGIS) replied September 13, 2016
Yes,these are : libeay32.dll, libiconv-2.dll, libintl-8.dll, libpq.dll, ssleay32.dll
AKNLEO replied May 23, 2019
Hello, I tried this but it does not work
[TatukGIS Layer]
Storage=PostGIS
Layer=RFU_Parcel
Dialect=POSTGRESQL
Libpq=192.168.70.51=Postgres 9.5 port=5432 dbname=rfu user=postgres password=pgrfu client_encoding=WIN1250
If you would like to answer the question please Sign In.
Rules
The Questions and Answers (Q & A) is intended to provide a means of communication between TatukGIS customers.
- Licensed users (with active maintenance play) of TatukGIS products may contribute to the Q & A content. Read-only access is available to anyone.
- Keep the content positive and professional.
- Be courteous to others by posting information when a question or issue asked on the Q & A is answered or resolved by other means (such as with help from TatukGIS technical support). Offer others at least a hint how the posted question was answered or the issue was resolved.
- The Q & A is not a replacement for TatukGIS technical support. TatukGIS team may or may not regularly follow or contribute content.