cx-oracle

How to extend OracleCursor class from cx_Oracle

半世苍凉 提交于 2019-12-24 06:49:08
问题 Using Python 2.7.12 and package cx_Oracle I'm trying to create an extended class of the what the package call OracleCursor. I simply want to inherit the methods from the superclass and extend with some custom methods. First I get the OracleCursor by import cx_Oracle conn = cx_Oracle.connect(username, password, dsn) cursor = conn.cursor() and I then have the following >>> type(cursor)Out[6]: OracleCursor >>> isinstance(cursor, cx_Oracle.Cursor) True One would think that it is achieved by class

How to bundle cx_oracle with Pyinstaller

拟墨画扇 提交于 2019-12-24 00:46:19
问题 My goal is to use Pyinstaller to bundle an exe file from a simple python script that uses Tkinter and cx_oracle to access a database. The python code is developed on a windows machine with Anaconda, cx_oracle package and oracle client installed. Then I need to run the exe file in many target windows machines without oracle client or Python. I am using Python 2.7 and Pyinstaller 3.1 on the development machine. I searched quite a while online but only found one tutorial on this: https://mail

cx_Oracle: Using PL/SQL RECORD types as arguments to stored procedures

大兔子大兔子 提交于 2019-12-23 23:19:41
问题 I'm attempting to call AP_VENDOR_PUB_PKG.CREATE_VENDOR from cx_Oracle (This is an Oracle R12 stored procedure) It requires an argument that is a predefined PL/SQL RECORD type. (AP_VENDOR_PUB_PKG.R_VENDOR_REC_TYPE) Here's my python code: connection = cx_Oracle.connect(...) cursor = connection.cursor() obj = cursor.var(cx_Oracle.Object, typename='AP_VENDOR_PUB_PKG.R_VENDOR_REC_TYPE') result = cursor.callproc('AP_VENDOR_PUB_PKG.CREATE_VENDOR', parameters=["1.0", "T", "T", "fnd_api.g_valid_level

cx_Oracle and the data source paradigm

送分小仙女□ 提交于 2019-12-23 20:52:46
问题 There is a Java paradigm for database access implemented in the Java DataSource . This object create a useful abstraction around the creation of database connections. The DataSource object keeps database configuration, but will only create database connections on request. This is allows you to keep all database configuration and initialization code in one place, and makes it easy to change database implementation, or use a mock database for testing. I currently working on a Python project

Named Parameters with a Oracle stored procedure in Python

为君一笑 提交于 2019-12-22 12:45:07
问题 Trying to call an existing stored procedure, but using named parameters, first parameter should retain default value (in this case NULL). I've spent way too long trying to get this working, any ideas? create or replace procedure so_test(p1 in varchar2 default null, p2 in varchar2 default null, p3 in varchar2 default null) as begin null; end; import cx_Oracle db = cx_Oracle.connect('/@XTS_DEV.CLIENT') cur = db.cursor() cur.callproc("so_test", ('X', 'Y', 'Z')) cur.callproc("so_test(p2=>:1, p3=>

cx_Oracle: distutils.errors.DistutilsSetupError: cannot locate Oracle include files even with SDK

吃可爱长大的小学妹 提交于 2019-12-22 10:00:11
问题 Trying to install cx_Oracle for Python 3.4 on Centos. I have installed Oracle client 11.2.0.1 (actually has two copies, as one requires encrypted connection while the other doesn't, so I have /usr/lib/oracle/11.2/client64 and /usr/lib/oracle/11.2.99/client64) $ echo $ORACLE_HOME /usr/lib/oracle/11.2/client64 $ python3.4 --version Python 3.4.3 I have the SDK installed: $ ls -all $ORACLE_HOME/sdk/include total 1640 drwxrwxr-x 2 root root 4096 Aug 15 2009 . drwxrwxr-x 4 root root 4096 Aug 15

Pass encoding parameter to cx_oracle from sqlalchemy

时光怂恿深爱的人放手 提交于 2019-12-22 08:59:30
问题 I'm using Oracle Database with UTF-16 encoding. The diacritics is correctly displayed when using directly cx_oracle client. Connection statement is like this: cx_Oracle.connect(username, password, conn_str, encoding='UTF-16', nencoding='UTF-16') However, now I'm building bigger application and I would like to use SQLalchemy in Flask . Code looks like this: from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy(app) db.Model.metadata.reflect(db.engine) class MyTable(db.Model): __table__ = db

Python - write headers to csv

你离开我真会死。 提交于 2019-12-22 08:47:44
问题 Currently i am writing query in python which export data from oracle dbo to .csv file. I am not sure how to write headers within file. try: connection = cx_Oracle.connect('user','pass','tns_name') cursor = connection.cursor() print "connected" try: query = """select * from """ .format(line_name) tmp = cursor.execute(query) results = tmp.fetchall() except: pass except: print IOError filename='{0}.csv'.format(line_name) csv_file = open(filename,'wb') if results: myFile = csv.writer(csv_file)

How to change environment variables in python?

懵懂的女人 提交于 2019-12-22 08:13:28
问题 i have a simple python script ( test.py ): import cx_Oracle from cx_Oracle tns = cx_Oracle.makedsn('10.10.1.3', 1521, 'etst') db = cx_Oracle.connect('test', 'test', tns) it is work if I run script with enviroument settings: export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib ./test.py Can I set environment variables in python script ? os.environ['LD_LIBRARY_PATH'] = "/usr/lib/oracle/11.2/client64/lib" os.putenv('LD_LIBRARY_PATH', "/usr/lib/oracle/11.2/client64/lib/") not work. 回答1: You

sqlalchemy fails to connect but cx_oracle succeeds

会有一股神秘感。 提交于 2019-12-22 01:08:22
问题 I'm attempting to connect to an oracle server in Python. I have this working in cx_Oracle, but when I try to connect using sqlalchemy it fails. The cx_Oracle code: import cx_Oracle import pandas as pd cx_connection = cx_Oracle.connect(user+'/' + pw + '@' + host + ':' + port + '/' + db) df = pd.read_sql(my_query, cx_connection) Executes and returns data from the database based on the query as expected. If I try the same connection with sqlalchemy: import sqlalchemy engine = sqlalchemy.create