首页 >后端开发 >Python教程 >Python连接Oracle

Python连接Oracle

大家讲道理
大家讲道理原创
2016-11-09 10:35:521318浏览

#!/usr/bin/env python
import time
start = time.clock()
 
import cx_Oracle
tns = cx_Oracle.makedsn('127.0.0.1', '1534', 'dsn')
db = cx_Oracle.connect('username', 'password', tns)
def sqlSelect(sql, db):
    cur=db.cursor()
    cur.execute(sql)
    result=cur.fetchall()
    cur.close()
    return result
 
sql_1 = " "
sql_2 = " "
sql_3 = " "
 
sql_list = [sql_1, sql_2, sql_3]
for sql in sql_list:
    result = sqlSelect(sql, db)
    print(result[0][0])
 
end = time.clock() 
print("\nRunning time: %f s" % (end - start))

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn