2015-04-01 80 views
1

代碼

這是我在Linux紅帽64位Pyodbc連接錯誤

import pyodbc 

print pyodbc.dataSources() 

print "Connecting via ODBC" 

conn = pyodbc.connect("DRIVER={NetezzaSQL};SERVER=localhost;PORT=5480;DATABASE=Database;UID=santiago;PWD=ha123;") 

錯誤

這是運行pyodbc當我收到真正的錯誤使用Python 2.6輸入的代碼。我不知道這種語言是什麼或它的意思?

{'ODBC': '', 'NetezzaSQL': '/usr/local/nz_7.2.0.3/lib64/libnzodbc.so'} 
Connecting via ODBC 
Traceback (most recent call last): 
    File "connect.py", line 41, in <module> 
conn = pyodbc.connect("DRIVER{NetezzaSQL};SERVER=localhost;PORT=5480;DATABASE=Database;UID=santiago;PWD=ha123;") 
pyodbc.Error: ('H00', '[H00] [unixODBC]Sre n/rpr trbtsaeepy\xc8 (33) (SQLDriverConnectW)') 

obdcinst.ini

這是obdcinst文件中使用

[ODBC Drivers] 
NetezzaSQL = Installed 

[NetezzaSQL] 
Driver   = /usr/local/nz_7.2.0.3/lib64/libnzodbc.so 
Setup   = /usr/local/nz_7.2.0.3/lib64/libnzodbc.so 
APILevel   = 1 
ConnectFunctions = YYN 
Description  = Netezza ODBC driver 
DriverODBCVer = 03.51 
DebugLogging  = false 
LogPath   = /tmp 
UnicodeTranslationOption = utf8 
CharacterTranslationOption = all 
PreFetch   = 256 
Socket   = 16384 

obdc.ini

這ODBC配置文件中使用

; 
; odbc.ini 
; 
[ODBC Data Sources] 
NZSQL = NetezzaSQL 


[NetezzaSQL] 
;Path of a driver used for database connection 
Driver    = /usr/local/nz_7.2.0.3/lib64/libnzodbc.so 

;A decription used to identify the database connection properties. 
Description   = NetezzaSQL ODBC 

;The name of a machine or IP address where the database is located. 
Servername   = 127.0.0.1 

;The port number to connect. 
Port     = 5480 

;The name of a database. 
Database    = dev 

;The name of a valid user. 
Username    = guest 

;The password for the user. 
Password    = password 

;Only Select SQL statements will be allowed if this field is checked. 
ReadOnly    = false 

;When this option is enabled and the application bindtype is same as backend 
;datatype the query performance will be faster.Query performance gain will be achieved 
;only for single select statements (not for batch queries).It also works in case when 
;application bind type is different than backend datatype but there are some restrictions on it. 
FastSelect   = false 

;When set to true, system tables will be included in the available table list. 
ShowSystemTables  = false 

;When set to true, use old (2.5) functionality for returning schemas in SQLTables. 
LegacySQLTables  = false 

;Specifies login timeout in seconds. 
LoginTimeout   = 0 

;Specifies query timeout in seconds. 
QueryTimeout   = 0 

;Specifies date format as follows - 
; 1: YMD 
; 2: MDY 
; 3: DMY 
DateFormat   = 1 

;When selected, driver treats SQL_C_NUMERIC buffers as SQL_C_CHAR buffers. 
NumericAsChar   = false 

;Return SQL_BIT as "1"/"0" when char. 
SQLBitOneZero   = false 

;When enabled, replaces all occurences of CRLF, CR and LF with a single space. 
StripCRLF    = false 

;Specifies level of security on the system 
securityLevel   = preferredUnSecured 

;Name of the Root CA certificate. 
caCertFile   = 

;Specifies maximum errors allowed. 0 value means no limit on loadMaxErrors value. 
;loadMaxErrors   = 1 

;If value is true, it rounds the data of numeric columns whose precision exceeds the precision defined. 
;loadRoundFraction  = 0 


[ODBC] 
IANAAppCodePage=4 
InstallDir=/opt/odbc32v51 
Trace=0 
TraceDll=/opt/odbc32v51/lib/odbctrac.so 
TraceFile=odbctrace.out 
UseCursorLib=0 

如果別的是必要的確定解決方案,請讓我知道。

回答

0

我不能告訴你錯誤的含義是什麼,因爲我不認識這門語言。但是,Netezza ODBC端口是5480,而您在連接方法中指定了5668。另外,您真正想要連接到的數據庫實際上是否名爲「數據庫」?

+0

我改變了屬性,因爲把私人信息放在網上並不好,但是我得到了正確的數據庫並且在原始代碼中包含了5480。我在Windows中使用具有原始屬性的python運行相同的代碼,它的工作原理,但在我的Linux機器上它不工作。 – fandangorightnow 2015-04-02 14:35:44

+0

您可能想要始終如一地更改它,否則它看起來像配置/參數錯誤(請參閱稍後在示例ODBC.ini中指定的端口) – ScottMcG 2015-04-02 15:24:14

+0

謝謝,我編輯了該問題。你認爲這可能是一個Python解釋器的問題? – fandangorightnow 2015-04-02 19:29:59