1、首先要下载安装cx_Oracle
注意:下载的cx_Oracle版本要与自己的python环境版本一致,否则可能连接数据库时报错。
2、数据库表结构
3、python代码
-
# -*- mode: python; coding: utf-8 -*-
-
#
-
# python operate oracle, contain insert、delete、update、select.
-
#
-
# @author liyulin
-
# @date 2014-11-07
-
import cx_Oracle
-
class PythonOralceUtil:
-
def __enter__(self):
-
self.conn = cx_Oracle.connect('testuser/testpwd@localhost/CHROMEBOOK')
-
self.cursor = self.conn.cursor()
-
return self
-
def __exit__(self, type, value, traceback):
-
self.cursor.close()
-
self.conn.close()
-
############################################
-
# 查询reg_codes中的所有数据
</