cx-oracle

How to pass a python array to an oracle stored procedure?

99封情书 提交于 2019-12-12 06:33:51
问题 I have a problem. When I pass a Python array: self.notPermited = [2,3] This is my procedure def select_ids_entre_amistades(self,cod_us,ids_not): lista = [] try: cursor = self.__cursor.var(cx_Oracle.CURSOR) print ids_not data = self.__cursor.arrayvar(cx_Oracle.NUMBER, ids_not) print data l_query = self.__cursor.callproc("SCHEMA.PROC_SELECT_IDS_ENT_AMISTADES", [cursor,cod_us,data]) lista = l_query[0] return lista except cx_Oracle.DatabaseError as ex: error, = ex.args print(error.message) return

cx_Oracle Package Not working inside Crontab

孤人 提交于 2019-12-12 05:29:06
问题 I am using cx_Oracle library in my python script. My code works fine if I directly execute by python script from Linux terminal but when I put it in crontab I am getting following error. !!DatabaseError: DPI-1047: Oracle Client library cannot be loaded: libclntsh.so: cannot open shared object file: No such file or directory. See https://oracle.github.io/odpi/doc/installation.html for help DPI-1005: unable to acquire Oracle environment handle !!Traceback (most recent call last): import cx

Search for name in cx_Oracle

巧了我就是萌 提交于 2019-12-12 05:27:36
问题 I have var='smth' and I need to check if var exists in the table 'smtb' I tried something this, but it does not work: rows=curs.fetchall() for row in rows: if var==row: print("Yes") When I print elements of rows, I get some pattern like this: ('element',) How can I check whether var exists in the table? 回答1: Don't do this in Python. If you want to search for something in a database table by far the quickest and most efficient way is to do it in SQL. Don't forget to use bind variables.

getting date fields from oracle in correct format using Python and cx-oracle

浪子不回头ぞ 提交于 2019-12-12 05:09:34
问题 I am retrieving a load of data from one oracle database and then inserting it into another non linked database that is structurally the same. I am doing it by doing: select * from xxx where id = parameter and Select COLUMN_NAME from user_tab_columns where table_name=xxx then with zip putting them in a dictionary as table_name:Data to build the insert from Problem is it is returning the date fields as datetime.datetime(99, 12, 31, 0, 0). I need this as 31-dec-2999. How can I get it to return

cx_Oracle equivalent of datetime64[ns]

感情迁移 提交于 2019-12-12 03:25:13
问题 Given the following kind of data in a column of a Pandas data frame (Pandas data type is datetime64[ns]: Contract_EffDt 1974-02-01 I want to import this (along with some string and int columns) into Oracle like this: import cx_Oracle as cx . . . cur.setinputsizes(25,25,255,255,25,25,25,255,255,25,25,cx.DATE,int) cur=con.cursor() cur.bindarraysize = 1000 cur.executemany('''insert into Table(Contract_ID,Plan_ID,Org_Type,Plan_Type,Offers_Part_D,SNP_Plan,\ EGHP,Org_Name,Org_Mkt_Name,Plan_Name

Sharing an Oracle database connection between simultaneous Celery tasks

痴心易碎 提交于 2019-12-12 02:49:21
问题 I'm working with Python2.7, Celery and cx_Oracle to access the Oracle database. I create a lot of tasks. Each task runs a query through cx_Oracle. Many of this tasks will run simultaneously. All tasks should share the same database connection. If I only launch one task, the query gets run correctly. However, if I launch several queries, I start getting this error message: [2016-04-04 17:12:43,846: ERROR/MainProcess] Task tasks.run_query[574a6e7f-f58e-4b74-bc84-af4555af97d6] raised unexpected:

Python 3.4: Loop and Append: Why Not Working With cx_Oracle and Pandas?

北战南征 提交于 2019-12-11 23:07:38
问题 For some reason, the following code only returns a dataframe of 10 rows instead of 20 (there are millions of rows in the SQL view). When I viewed the output from print(data2), it showed the first 10 rows as a DataFrame, but the next DataFrame was empty. import cx_Oracle as cx import pandas as pd conn = cx.Connection("username/pwd@server") data = pd.DataFrame([]) SQL1 = '''SELECT * FROM TABLE_MV where rownum between ''' for i in range(1, 20, 10): lower = i upper = i+9 SQL3 = SQL1 + str(lower)

RobotFramework : cx_Oracle - FAIL : InternalError: No Oracle error?

≯℡__Kan透↙ 提交于 2019-12-11 22:49:05
问题 Couldn't find a solution for my problem using search so I created this topic. I'm having problems when connecting to Oracle database using DataBase libary and cx_Oracle module. In python import cx_Oracle works great (returns no error), but when I try to connect to DB on RobotFramework with Connect To Database Using Custom Params | cx_Oracle | 'user', 'pass', 'host/db' I get an error : FAIL : InternalError: No Oracle error? If I try to connect to database using Connect To Database |

Fetching file from db and save it into local folder using python

為{幸葍}努か 提交于 2019-12-11 18:39:17
问题 I am trying to retrieve data from database and save it into excel/csv file, There is column containing blob data , i have to save that data in .zip format in a local folder with name of that file (i.e., the name of the file containing that blob data, which is already a column value in my database). I have written the below code to store all the non blob column in my excel but i am not able to fetch that blob column from db and save it into the folder. Please suggest. import os import cx

Django can't clear database cache on Oracle backend

可紊 提交于 2019-12-11 18:01:44
问题 I have one row in my oracle cache table. I'm trying to clear it using standard django way: from django.core.cache import cache cache.clear() But it doesn't work! The row is still in my cache table. So I run python manage.py sell and put some code from DatabaseCache.clear() method: from django.db import connections table = connections['cache'].ops.quote_name('ws_cache_table') cursor = connections['cache'].cursor() cursor.execute('DELETE FROM %s' % table) But it doesn't work either... I don't