Python 3.3-与Oracle数据库连接

Python 3.3-与Oracle数据库连接,python,oracle,python-3.3,Python,Oracle,Python 3.3,python 3.3是否有与Oracle数据库连接的模块?哪一个最容易使用?类似于mysql模块,只适用于Oracle 最好是10g版本,但11g就可以了。有:cx\U Oracle # Install --> You should have oracle installed otherwise exception will be raised pip install cx_Oracle import cx_Oracle con = cx_Oracle.connect('python

python 3.3是否有与Oracle数据库连接的模块?哪一个最容易使用?类似于mysql模块,只适用于Oracle


最好是10g版本,但11g就可以了。

有:
cx\U Oracle

# Install --> You should have oracle installed otherwise exception will be raised

pip install cx_Oracle

import cx_Oracle

con = cx_Oracle.connect('pythonhol/welcome@127.0.0.1/orcl')
print con.version

con.close()


如果您使用的是python3

pip3 install cx_Oracle
如何连接oracle并获取oracle时间:

#!/usr/bin/python3
#coding=utf8


# import module
import cx_Oracle 

con = cx_Oracle.connect('username/password@databasename')

# create cursor
cursor = con.cursor()

# execute sql
cursor.execute('select sysdate from dual')

# fetch one data, or fetchall()
data = cursor.fetchone()

print('Database time:%s' % data)

# close cursor and oracle
cursor.close()
con.close()

谢谢非常有用:)我真的需要Oracle客户机才能工作吗?难道没有直接的JDBC连接那么简单吗?泰。