我使用带有 DSN 的 Oracle 驱动程序,对我来说它连接:
db = pyodbc.connect('DSN=my_test_db;PWD=tiger')
print('-' * 20)
try:
c = db.cursor()
rs = c.execute("select * from v$version where banner like 'Oracle%'")
for txt in c.fetchall():
print('%s' % (txt[0]))
finally:
db.close()