从pypyodbc连接到Oracle11g DB

时间:2015-06-08 20:00:35

标签: pypyodbc

这里是相对初学级别的python dev。我只是无法从pypyodbc

连接到Oracle
import pypyodbc as pyodbc
connstr = 'DSN = IDW;PWD=XXXXX'
connection = pyodbc.connect(connstr)

以下列错误:

File "C:\Users\PRXM\Desktop\JobReadings\PythonIDE\eclipse-standard-luna-R-win32-x86_64\eclipse\plugins\org.python.pydev_4.1.0.201505270003\pysrc\pydevd.py", line 1709, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
File "C:\Users\PRXM\workspace\tests\gettingstarted.py", line 10, in <module>
    connection = pyodbc.connect(connstr)
File "C:\Users\PRXM\Desktop\JobReadings\PythonIDE\Anaconda_64\lib\site-packages\pypyodbc.py", line 2434, in __init__
    self.connect(connectString, autocommit, ansi, timeout, unicode_results, readonly)
File "C:\Users\PRXM\Desktop\JobReadings\PythonIDE\Anaconda_64\lib\site-packages\pypyodbc.py", line 2483, in connect
    check_success(self, ret)
File "C:\Users\PRXM\Desktop\JobReadings\PythonIDE\Anaconda_64\lib\site-packages\pypyodbc.py", line 988, in check_success
    ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi)
File "C:\Users\PRXM\Desktop\JobReadings\PythonIDE\Anaconda_64\lib\site-packages\pypyodbc.py", line 964, in ctrl_err
    raise Error(state,err_text)
pypyodbc.Error: (u'IM002', u'[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified')

1 个答案:

答案 0 :(得分:2)

试试这个:

Connection_String = 'Driver={Oracle in OraClient11g_home1};DBQ=MyDB;Uid=MyUser;Pwd=MyPassword;'