Python connects to Oracle

大家讲道理
Release: 2016-11-09 10:35:52
Original
1315 people have browsed it

#!/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))
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template