oracle

cx_Oracle SELECT statement with WHERE clause and single quote

cx_Oracle SELECT statement with WHERE clause and single quote Question: import cx_Oracle dsn_tns = cx_Oracle.makedsn(‘**********’, ‘*******’, service_name=’***’) conn = cx_Oracle.connect(user=’******’, password=’*******’, dsn=dsn_tns) c = conn.cursor() c.execute(‘select username,created from dba_users where username=’USERNAME’ ‘) for row in c: print (row[0], ‘-‘, row[1]) # this only shows the first two columns. To add an additional column you’ll need …

Total answers: 2

Error Connecting virtual machine to oracle, using python (error DPY-4011)

Error Connecting virtual machine to oracle, using python (error DPY-4011) Question: I’m using the oracledb library to connect my python application to an oracle database. I can connect normally using python on my computer, but I have a virtual machine, running Ubuntu, which is using the same network as the computer, that cannot connect. here …

Total answers: 1

Extract data from Oracle Database with Pandas without Oracle Instant Client

Extract data from Oracle Database with Pandas without Oracle Instant Client Question: I’m trying to connect to an Oracle Database using pandas + sqlalchemy using this code: from sqlalchemy.engine import create_engine import pandas as pd DIALECT = ‘oracle’ SQL_DRIVER = ‘cx_oracle’ USERNAME = ‘USER’ PASSWORD = ‘PASS’ HOST = ‘HOST’ PORT = 1521 SERVICE = …

Total answers: 1

Convert multiple SQL CASE statements to Pandas syntax

Convert multiple SQL CASE statements to Pandas syntax Question: CASE WHEN a.sch_end_locn_id != a.ats_sta_id AND a.PLC_ACTUAL_DEPART_TIME IS NULL AND a.BEACON_ACTUAL_DEPART_TIME IS NULL THEN CASE WHEN a.ITRAC_ACTUAL_DEPART_TIME IS NOT NULL THEN a.ITRAC_ACTUAL_DEPART_TIME WHEN a.PLC_ACTUAL_DEPART_TIME_CLEAR IS NOT NULL THEN a.PLC_ACTUAL_DEPART_TIME_CLEAR – 15/(24*60*60) WHEN a.PLC_ACTUAL_ARRIVE_TIME_DWELL IS NOT NULL THEN a.PLC_ACTUAL_ARRIVE_TIME_DWELL + a.median_dwell WHEN a.PLC_ACTUAL_ARRIVE_TIME IS NOT NULL THEN …

Total answers: 1

Runtime variable for Oracle DATE type in Airflow

Runtime variable for Oracle DATE type in Airflow Question: I’m trying to define task that requires a run-time parameter (let’s call it ‘batch_dt’) in Apache Airflow. I’m using OracleStoredProcedureOperator and the parameter of the procedure is of database type date. procedure use_dates ( i_date in date, i_date2 in date, i_date3 in date ); However I’m …

Total answers: 2

With python-oracledb what does 'DPY-4027: no configuration directory to search for tnsnames.ora' mean

With python-oracledb what does 'DPY-4027: no configuration directory to search for tnsnames.ora' mean Question: With the python-oracledb driver the code: import oracledb cs = "MYDB" c = oracledb.connect(user=’cj’, password=mypw, dsn=cs) gives the error: oracledb.exceptions.DatabaseError: DPY-4027: no configuration directory to search for tnsnames.ora The same error also occurs in a second case: import oracledb cs = …

Total answers: 1

How to use input/command from selected button tkinter python

How to use input/command from selected button tkinter python Question: This may be tricky but I’ll try to put it clear. i have created two buttons, 1st button search folder and select individual filename as input, 2nd button select folder and take its directory as input and read all its files inside. I want to …

Total answers: 2

Returning Oracle query results in JSON format

Returning Oracle query results in JSON format Question: I want to create a python script to run an oracle query and store each resulting row into a JSON file. So far, I have completed the oracle connection, the query execution and the printing of each resulting row. Note: I’m using cx_Oracle import cx_Oracle try: con …

Total answers: 1

Can't properly read SQL table in python: varchar columns imported as comma-separated characters / tuples

Can't properly read SQL table in python: varchar columns imported as comma-separated characters / tuples Question: I’m connecting to a Oracle database using the following code: jar = ojdbc8.jar path jvm_path = jvm.dll path args = ‘-Djava.class.path=%s’ % jar jpype.startJVM(jvm_path, args) con = jaydebeapi.connect("oracle.jdbc.driver.OracleDriver", url,[user, password], jar) The connection works fine, however the data is …

Total answers: 2

How to i read the contents of Oracle stored procedures using Python

How to i read the contents of Oracle stored procedures using Python Question: I am trying to read the contents/code of a stored procedure using python. i used cx_Oracle function to establish the connection with oracle database. here is the code import cx_Oracle as co import pandas as pd dsn_tsn = co.makedsn(ip,port,SID) db=co.connect(username,password,dsn_tsn) cursor = …

Total answers: 3