cx-oracle

IN clause for Oracle Prepared Statement in Python cx_Oracle

IN clause for Oracle Prepared Statement in Python cx_Oracle Question: I’d like to use the IN clause with a prepared Oracle statement using cx_Oracle in Python. E.g. query – select name from employee where id in (‘101’, ‘102’, ‘103’) On python side, I have a list [101, 102, 103] which I converted to a string …

Total answers: 4

CX_Oracle – import data from Oracle to Pandas dataframe

CX_Oracle – import data from Oracle to Pandas dataframe Question: Hy, I’m new in python and I want import some data from a Oracle Database to python (pandas dataframe) using this simple query SELECT* FROM TRANSACTION WHERE DIA_DAT >=to_date(‘15.02.28 00:00:00’, ‘YY.MM.DD HH24:MI:SS’) AND (locations <> ‘PUERTO RICO’ OR locations <> ‘JAPAN’) AND CITY=’LONDON’ What I …

Total answers: 1

Insert Python datetime to Oracle column of type DATE

Insert Python datetime to Oracle column of type DATE Question: I am trying to store a Python datetime object in an ORACLE column of type date. so far, I have used, rpt_time = time.strftime(‘%Y-%m-%d %H:%M:%S’) or rpt_time = str(datetime.datetime.now()) but all are giving ORA-01843: not a valid month I am really confused how to insert …

Total answers: 4

Issue building cx_Oracle – libclntsh.so.11.1 => not found

Issue building cx_Oracle – libclntsh.so.11.1 => not found Question: I’m trying to build cx_Oracle for a Python 2.7.2 and Oracle 11g installation but the built cx_Oracle.so cannot find libclntsh.so.11.1 so importing cx_Oracle in Python fails. /mypath/cx_Oracle-5.1.1/build/lib.linux-x86_64-2.7-11g]$ ldd cx_Oracle.so libclntsh.so.11.1 => not found libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ae9be290000) libc.so.6 => /lib64/libc.so.6 (0x00002ae9be4ab000) /lib64/ld-linux-x86-64.so.2 (0x000000389b600000) I have libclntsh.so.11.1 …

Total answers: 5

cx_Oracle and Exception Handling – Good practices?

cx_Oracle and Exception Handling – Good practices? Question: I’m trying to use cx_Oracle to connect to an Oracle instance and execute some DDL statements: db = None try: db = cx_Oracle.connect(‘username’, ‘password’, ‘hostname:port/SERVICENAME’) #print(db.version) except cx_Oracle.DatabaseError as e: error, = e.args if error.code == 1017: print(‘Please check your credentials.’) # sys.exit()? else: print(‘Database connection error: …

Total answers: 2

cx_Oracle: How do I iterate over a result set?

cx_Oracle: How do I iterate over a result set? Question: There are several ways to iterate over a result set. What are the tradeoff of each? Asked By: Mark Harrison || Source Answers: The canonical way is to use the built-in cursor iterator. curs.execute(‘select * from people’) for row in curs: print row You can …

Total answers: 3