Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to MS SQL Server #140

Open
reignmaker opened this issue Nov 20, 2023 · 1 comment
Open

Unable to connect to MS SQL Server #140

reignmaker opened this issue Nov 20, 2023 · 1 comment

Comments

@reignmaker
Copy link

reignmaker commented Nov 20, 2023

Hello,

Thank you for maintaining this extension!
Does this extension allow executing write queries on MS SQL Server?

Also I have some difficulties on setting up the extension and would like to get some help with it.

I went through the readme step by step installing all the dependencies (unixodbc-dev (2.3.11-1), odbc-postgresql (1:16), freetds-common (1.1.6-1.1), freetds-dev (1.1.6-1.1), freetds-bin (1.1.6-1.1)) and the extension itself make && sudo make install successfully.

The host system is Ubuntu 20.04.3 LTS and the Postgres 12.

/etc/odbcinst.ini:

[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.3.so.2.1
UsageCount=1

[PostgreSQL ANSI]
Description=PostgreSQL ODBC driver (ANSI version)
Driver=psqlodbca.so
Setup=libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=1

[PostgreSQL Unicode]
Description=PostgreSQL ODBC driver (Unicode version)
Driver=psqlodbcw.so
Setup=libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=1
CREATE EXTENSION odbc_fdw;

CREATE SERVER sqlserver_fdw FOREIGN DATA WRAPPER odbc_fdw
  OPTIONS (
   odbc_DRIVER '{ODBC Driver 18 for SQL Server}',
   "odbc_Server" '{***.***.windows.net}',
   "odbc_Database" '${dbname}',
   "odbc_UID" '{userName}',
   "odbc_PWD" '{paSSworD}'
  );

CREATE USER MAPPING FOR user
  SERVER sqlserver_fdw
  OPTIONS ("odbc_UID" '{userName}', "odbc_PWD" '{paSSworD}');


CREATE FOREIGN TABLE IF NOT EXISTS public.mssql_table (
    id integer NULL,
    ...
)
    SERVER sqlserver_fdw
    OPTIONS (schema 'schema_name', table 'table_name');

Attempting to select something (like select public.mssql_table or select * from odbctableslist('sqlserver_fdw', 1)) returns an error:

ERROR:  Connecting to driver 

SQL state: 58000

Am I missing something?

@michelle0809
Copy link

I have same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants