2014-09-29 63 views
0

我正在运行Ubuntu 14.04.1 86_x64服务器,我一直在试图弄清楚如何连接到MSSQL 2012 Contained Database。我一直在尝试使用FreeTDS驱动程序的pymssql 2.1.0。基于pymssql网站,我确定问题出在FreeTDS驱动程序上。在Ubuntu上使用python连接到MSSQL包含的数据库?

我用tsql -H SERVER -p PORT -U USERNAME -P PASSWORD -D DATABASE和我得到的错误:

Msg 18456 (severity 14, state 1) from SERVER Line 1:

"Login failed for user 'USERNAME'." 

Error 20002 (severity 9):

Adaptive Server connection failed 

There was a problem connecting to the server

我没有连接到MSSQL 2008数据库,不支持包含的数据库同样的问题。另外,我无法控制数据库上的设置。

回答

0

发现pymssql 2.1.1将其作为“与Azure的兼容性”的一部分进行修复。

解决这个问题的代码是在_mssql.pyx中的606-613行,它可以在github上找到。我已将这些线条仅供参考。

# Put the DB name in the login LOGINREC because it helps with connections to Azure 
if database: 
    if FREETDS_SUPPORTS_DBSETLDBNAME: 
     dbname_bytes = database.encode('ascii') 
     dbname_cstr = dbname_bytes 
     DBSETLDBNAME(login, dbname_cstr) 
    else: 
     log("_mssql.MSSQLConnection.__init__(): Warning: This version of FreeTDS doesn't support selecting the DB name when setting up the connection. This will keep connections to Azure from working.") 
相关问题