cx-oracle

cx_Oracle - How do I access Oracle from Python?

How do I get started? ...

cx_Oracle - what is the best way to iterate over a result set?

There are several ways, what is the best one? ...

cx_Oracle: how do I get the ORA-xxxxx error number?

In a try/except block, how do I extract the Oracle error number? ...

Python reading Oracle path

On my desktop I have written a small Pylons app that connects to Oracle. I'm now trying to deploy it to my server which is running Win2k3 x64. (My desktop is 32-bit XP) The Oracle installation on the server is also 64-bit. I was getting errors about loading the OCI dll, so I installed the 32 bit client into C:\oracle32. If I add this...

cx_Oracle & Connecting to Oracle DB Remotely

How do you connect to a remote server via IP address in the manner that TOAD, SqlDeveloper, are able to connect to databases with just the ip address, username, SID and password? Whenever I try to specify and IP address, it seems to be taking it locally. In other words, how should the string for cx_Oracle.connect() be formatted to a no...

Newbie Python Question about tuples

I am new to Python, and I'm working on writing some database code using the cx_Oracle module. In the cx_Oracle documentation they have a code example like this: import sys import cx_Oracle connection = cx_Oracle.Connection("user/pw@tns") cursor = connection.cursor() try: cursor.execute("select 1 / 0 from dual") except cx_Oracle.D...

cx_oracle and oracle 7 ?

Hello guys At work we have Oracle 7. I would like to use python to access the DB. Has anyone done that or knows how to do it? I have Windows XP, Python 2.6 and the cx_oracle version for python 2.6 However, when I try to import cx_oracle i get the following error: ImportError: DLL load failed the module could not be found Any help is...

Getting column info in cx_oracle when table is empty?

I am working on an a handler for the python logging module. That essentially logs to an oracle database. I am using cx_oracle, and something i don't know how to get is the column values when the table is empty. cursor.execute('select * from FOO') for row in cursor: # this is never executed because cursor has no rows print '%s\...

cx_Oracle And User Defined Types

Does anyone know an easier way to work with user defined types in Oracle using cx_Oracle? For example, if I have these two types: CREATE type my_type as object( component varchar2(30) ,key varchar2(100) ,value varchar2(4000)) / CREATE type my_type_tab as table of my_type / And then a procedure in package my_package as follows:...

Help me understand the difference between CLOBs and BLOBs in Oracle

This is mainly just a "check my understanding" type of question. Here's my understanding of CLOBs and BLOBs as they work in Oracle: CLOBs are for text like XML, JSON, etc. You should not assume what encoding the database will store it as (at least in an application) as it will be converted to whatever encoding the database was config...

What is the difference between converting to hex on the client end and using rawtohex?

I have a table that's created like this: CREATE TABLE bin_test (id INTEGER PRIMARY KEY, b BLOB) Using Python and cx_Oracle, if I do this: value = "\xff\x00\xff\x00" #The string represented in hex by ff00ff00 self.connection.execute("INSERT INTO bin_test (b) VALUES (rawtohex(?))", (value,)) self.connection.exec...

Python + CGI script cannot access environment variables

I'm coding a webservice on python that uses an Oracle database. I have cx_Oracle installed and working but I'm having some problems when I run my python code as CGI using Apache. For example the following code works perfectly at the command line: #!/usr/bin/python import os import cx_Oracle import defs as df os.putenv('ORACLE_HOME...

cx_Oracle and the data source paradigm

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 initializ...

Error on connecting to Oracle from py2exe'd program: Unable to acquire Oracle environment handle

My python program (Python 2.6) works fine when I run it using the Python interpreter, it connects to the Oracle database (10g XE) without error. However, when I compile it using py2exe, the executable version fails with "Unable to acquire Oracle environment handle" at the call to cx_Oracle.connect(). I've tried the following with no joy...

cx_Oracle MemoryError when reading lob

When trying to read data from a lob field using cx_Oralce I’m receiving “exceptions.MemoryError”. This code has been working, this one lob field seems to be too big. Example: xml_cursor = ora_connection.cursor() xml_cursor.arraysize = 2000 try: xml_cursor.execute(“select xml_data from xmlTable where id = 1”) for row_data in xml...

Return the number of affected rows from a MERGE with cx_oracle

How can you get the number of affected rows from executing a "MERGE INTO..." sql command within CX_Oracle? When ever I execute the MERGE SQL on cx_oracle, I get a cursor.rowcount of -1. Is there a way to get the number of rows affected by the merge? ...

Help installing cx_Oracle

I'm trying to install the cx_Oracle for Python 2.6, but it is failing. I don't know enough about C or MS Vis. Studio's compiler to even approach fixing it myself. This is what is output on the command line: C:\pydev\cx_Oracle-5.0.1>C:\python26\python setup.py install running install running build running build_ext ...

importing cx_Oracle and kinterbasdb returns error

Greetings, everybody. I'm trying to import the following libraries in python: cx_Oracle and kinterbasdb. But, when I try, I get a very similar message error. *for cx_Oracle: Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: Não foi possível encontrar o procedimento especificado. (translation: It wa...

Changing schema using cx_Oracle

Well, I hope this is not a duplicate, the search did not yield anything useful. I have been toying with cx_Oracle for the past few days, installing and using it. Everything went fine until I reached my current problem: I'd like to change my schema. If I were using sqlplus a simple 'alter session set current_schema=toto;' would do, but I...

How do I get cx_Oracle to work on 64-bit Itanium Windows?

I'm running Windows Server 2003 on a 64-bit Itanium server which is also running 64-bit Oracle 10.2, and I'd like to install cx_Oracle for Python 2.5. I've used cx_Oracle before many times on both Windows and Linux, and I've also compiled it before on 32 bit versions of those platforms, but I've never tried an IA64 compile. None of the...