时间:2021-07-01 10:21:17 帮助过:12人阅读
# python连接oracle数据
## 介绍
-----------------------------
- python 连接oracle数据库,可以使用cx_oracle模块
- 使用如下命令安装
```
python -m pip install cx_oracle --pre
```
## 连接oracle代码
-----------------------------
```python
import cx_oracle
# 设置
dsn = cx_oracle.makedsn("192.168.0.233", 1521, "tongji")
# 连接
conn = cx_oracle.connect("sas","tongji123",dsn)
curs = conn.cursor()
sql = ‘select * from case_info where rownum<10‘
rr = curs.execute (sql)
row = curs.fetchone()
print row[0]
# 关闭
curs.close()
conn.close()
```
python连接Oracle数据库
标签:one int cas import rownum rom close cursor nec