亲爱的Stackoverflow大师,
我在Windows上从PostgreSQL 9.3连接到MS SQL Server(2008)时遇到问题。我正在尝试通过DBI-Link DBD :: ODBC for Sql Server进行连接。 我想帮助您解决这个问题,或者指出在Windows上从PostgreSQL与SQL Server进行通信的另一种方式。
驱动程序似乎正在工作,因为当我添加错误的凭据时,我得到:
Severity: ERROR, Code: XX000, Line: 2117, Position: ErrorMessage: DBI
connect('Driver={SQL
Server};Server=10.XX.YY.ZZ\MyInstance','a_user',...) failed:
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user
'a_user'. (SQL-28000) at line 37. at line 35.
我用来创建连接的查询(在Postgres中)是:
UPDATE
pg_catalog.pg_settings
SET
setting =
CASE WHEN 'dbi_link' = ANY(string_to_array(setting, ','))
THEN setting
ELSE 'dbi_link,' || setting
END
WHERE
name = 'search_path'
;
SELECT make_accessor_functions(
'dbi:ODBC:Driver={SQL Server};Server=10.XX.YY.ZZ\MyInstance',
'a_user',
'Some_Password',
'---
AutoCommit: 1
RaiseError: 1
',
NULL,
NULL,
NULL,
'dbo'
);
我得到的错误(看起来也像连接)是:
Severity: ERROR, Code: XX000, Line: 2117, Position:
ErrorMessage: Could not connect to database
data source: dbi:ODBC:Driver={SQL Server};Server=10.XX.YY.ZZ\MyInstance
user: a_user
password: Some_Password
dbh attributes:
---
AutoCommit: 1
RaiseError: 1
[Microsoft][ODBC SQL Server Driver][SQL Server]Changed database context to 'master'. (SQL-01000)
[Microsoft][ODBC SQL Server Driver][SQL Server]Changed language setting to us_english. (SQL-01000) at line 35.
我的系统:
OS: Windows 7 64-bit
PostgreSQL: 9.3
Perl: Strawberry Perl 5.14.3
Python: 3.4
由于