pramsey / pgsql-ogr-fdw

PostgreSQL foreign data wrapper for OGR
MIT License
239 stars 34 forks source link

ODBC data source works in commandline but not pgsql #114

Closed zcattacz closed 8 years ago

zcattacz commented 8 years ago

I am on windows 7 32bit, running pgsql 9.6 with pgsql-ogr-fdw extension binaries from the buildbot http://winnie.postgis.net/download/windows/pg96/buildbot/extras/ The same data source string works perfectly in command line:

C:\Program Files\PostgreSQL\9.6\bin>ogr_fdw_info.exe -s "ODBC:fdwusr/***@my_db,xtab_ln2"
Layers:
  xtab_ln2

but copying the result of

    C:\Program Files\PostgreSQL\9.6\bin>ogr_fdw_info.exe -s "ODBC:fdwusr/***@my_db,xtab_ln2" -l "xtab_ln2"

CREATE SERVER myserver
  FOREIGN DATA WRAPPER ogr_fdw
  OPTIONS (
    datasource 'ODBC:fdwusr/***@my_db,xtab_ln2',
    format 'ODBC' );

CREATE FOREIGN TABLE xtab_ln2 (
  fid bigint,
  geom Geometry(Geometry),
  pd_date date,
  qty bigint,
  ....
) SERVER myserver
OPTIONS (layer 'xtab_ln2');

only gives me this error in pgsql.

ERROR: unable to connect to data source "ODBC:fdwusr/***@my_db,xtab_ln2"
  Hint: Unable to initialize ODBC connection to DSN for fdwusr/***@my_db,xtab_ln2,
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Since the session is not established, the system build-in tracing function gives no log of these attempts. there seems no way for me to know what is passed into the odbc driver. I am out of ideas what is going on...

Another question, regarding the data source string format: what should one do if you have "@" or "/" in their password ?

Any insight? Thanks.

zcattacz commented 8 years ago

Silly me, my DSN is created on user-level, while pgsql is running as service under network_service account. it sure won't work... Creating a system DSN fixed the issue.