oracle

Python not able to save some CLOB xml into xml file

Python not able to save some CLOB xml into xml file Question: I have this xml saved as CLOB in my oracle database: <?xml version=”1.0″ encoding=”UTF-8″?> <DCResponse> … </DCResponse> and with this python code I am able to save content into xml file: sql = “select extract(xmltype.createxml(xml), ‘//DCResponse’).getStringVal() from table t where id = 2” …

Total answers: 2

Blob data from Oracle to text file using python

Blob data from Oracle to text file using python Question: I have been trying to get the blob data from oracle into a text file using Python. I couldn’t find the answer on any of the other links. Below is my code : sql_string = “””select event_id ,blob_length ,blob field from table””” cur.execute(sql_string) path = …

Total answers: 4

How to pretty format the printing of SQL Queries in SQLAlchemy?

How to pretty format the printing of SQL queries in SQLAlchemy Question: I’m using SQLAlchemy to generate PL/SQL on the fly using compile and setting the dialect and compile_kwargs arguments (e.g., using str(ins.compile(dialect=oracle.dialect(), compile_kwargs={‘literal_binds’: True}))). This works fine, except the output is not formatted in the most pretty SQL statement ever. For example, one of …

Total answers: 5

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

Joining CSV or Tables

Joining CSV or Tables Question: I have two csv fies with different columns. Table1 title stage jan time darn 3.001 0.421 5/23/2016 13:14 darn 2.054 0.1213 5/24/2016 14:14 ok 2.829 1.036 5/23/2016 14:14 five 1.115 1.146 5/23/2016 17:14 three 2 5 5/23/2016 21:14 Table 2 title mar apr may jun date darn 0.631 1.321 0.951 …

Total answers: 2

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

Retrieving identity of most recent insert in Oracle DB 12c

Retrieving identity of most recent insert in Oracle DB 12c Question: I’d like to have returned to me (via cx_oracle in python) the value of the Identity that’s created for a row that I’m inserting. I think I can figure out the python bit on my own, if someone could please state how to modify …

Total answers: 5

Oracle connection string with at sign @ in pasword

Oracle connection string with at sign @ in pasword Question: I have a code that connect to oracle using connection string: conn = cx_Oracle.connect(‘username/password@server:port/services’) But the problem is my password contain @ character so it may become conn = cx_Oracle.connect(‘username/p@ssword@server:port/services’) it return DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified I use Django with …

Total answers: 5

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