python-oracledb (for example, because cx has nothing to do with Oracle Advertising and Customer Experience (CX) or to better align with the name of the Node.js node-oracledb driver). python-oracledb for Python 3.6 or earlier available on PyPI, so in outdated Python environments, cx_Oracle might still be useful. cursor object of cx_Oracle defines some attributes in addition to those specified in those specified in PEP 249: _get_oci_attr | |
_set_oci_attr | |
arraysize | also in PEP |
arrayvar | |
bindarraysize | |
bindnames | |
bindvars | |
callfunc | |
callproc | also in PEP |
close | |
connection | also in PEP |
description | also in PEP |
execute | also in PEP |
executemany | also in PEP |
executemanyprepared | |
fetchall | also in PEP |
fetchmany | also in PEP |
fetchone | also in PEP |
fetchraw | |
fetchvars | |
getarraydmlrowcounts | |
getbatcherrors | |
getimplicitresults | |
inputtypehandler | |
lastrowid | also in PEP |
outputtypehandler | |
parse | |
prefetchrows | |
prepare | |
rowcount | also in PEP |
rowfactory | |
scroll | also in PEP |
scrollable | |
setinputsizes | also in PEP |
setoutputsize | also in PEP |
statement | |
var |
import cx_Oracle as cxora
con = cxora.connect(user='[rene]', dsn='db')
print("Database version:", con.version)
print("Current schema: ", con.current_schema)
print("Internal name: ", con.internal_name)
# print(dir(con))
cursor() is a method, not an attribute! con.cursor().execute('create table tq84_cx_Oracle(a number, b varchar2(20))')
ins = con.cursor()
sql = 'insert into tq84_cx_Oracle values (:a, :b)'
ins.execute (sql, dict(a= 42, b='Hello world') )
ins.executemany(sql,[dict(a= 99, b='Ninety-nine'),
dict(a=None, b='null' ),
dict(a= -1, b='minus one' )])
ins = con.cursor()
sql = 'insert into tq84_cx_Oracle values (:1, :2)'
ins.executemany(sql, [[1, 'one' ],
[2, 'two' ],
[3, 'three'],
[4, 'four' ],
[5, 'five' ]])
con.commit()
sel = con.cursor()
sel.execute('select * from tq84_cx_Oracle where b like :b', b = '%i%')
for a, b in sel.fetchall():
print(f'{a:>3} {b}')
con.cursor().execute('drop table tq84_cx_Oracle')
con.close()
cx_Oracle to