installing cx_Oracle

  • Thread starter Rodrigo Daunaravicius
  • Start date
R

Rodrigo Daunaravicius

I can't get this configuration working:
cx_Oracle 4.0.1
Oracle 8.0.6
Python 2.3.3
Win NT4.0 SP6fc

My first shot at the problem was just running the installation thingie
pre-built for win32/python2.3/Oracle8i. It installed with no complaints but
I can't import the module (can't find OCIEnvCreate entry point in the
OCI.dll library).
This version was built for Oracle 8.1.7, so I figure that must be the
problem.

Then I downloaded the sources, but can't build them. After a fair amount of
fiddling with setup.py and some of the C header files to compensate for the
unusual file structure of my Oracle Client installation and for the use of
the gcc compilator instead of Visual Studio, I got stuck at this point:

:>python setup.py -build -c mingw32 install
:running build
:running build_ext
:building 'cx_Oracle' extension
:D:\minGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Id:\orant\oci80\include
:-Id:\orant\rdbms80\demo -ID:\Python23\include -ID:\Python23\PC -c
:cx_Oracle.c -o build\temp.win32-2.3\Release\cx_oracle.o
:"-DBUILD_TIME="""June 04, 2004 16:42:10"""
:In file included from cx_Oracle.c:63:
:Environment.c: In function `Environment_New':
:Environment.c:78: warning: implicit declaration of function `OCIEnvCreate'
:[follows a bunch of declaration errors for anything that's named
:OCIwhatever]


According to the Oracle Docs, "OCIEnvCreate creates and initializes an
environment for OCI functions to work under".

So my uneducated guess is that this OCIEnvCreate function is not present in
Oracle 8.0.6, but I can't find anything in the docs that hints to it.


1. Is there a way around this OCIEnvCrete problem?

2. Is there an alternative to cx_Oracle that works out of the box with
Oracle 8.0.6? (tryed DCOracle2, but couldn't make it work with Python2.3
AND without Zope)

3. Should I give up cx_Oracle and stick with ODBC?

4. Should I give up python and stick with Access VBA? (sorry, bad joke)



Any insight would be helpful (even another forum where I could forward this
specific question).

Thanks in advance,
Rodrigo Daunaravicius
 
D

David Fraser

Rodrigo said:
3. Should I give up cx_Oracle and stick with ODBC?

4. Should I give up python and stick with Access VBA? (sorry, bad joke)

Sorry this doesn't answer your questions, but since you're on Windows,
you may want to use one of the ADO wrappers for Python ... if you can't
get this working

David
 
A

Aurelio Martin

Rodrigo said:
I can't get this configuration working:
cx_Oracle 4.0.1
Oracle 8.0.6
Python 2.3.3
Win NT4.0 SP6fc

My first shot at the problem was just running the installation thingie
pre-built for win32/python2.3/Oracle8i. It installed with no complaints but
I can't import the module (can't find OCIEnvCreate entry point in the
OCI.dll library).
This version was built for Oracle 8.1.7, so I figure that must be the
problem.

Then I downloaded the sources, but can't build them. After a fair amount of
fiddling with setup.py and some of the C header files to compensate for the
unusual file structure of my Oracle Client installation and for the use of
the gcc compilator instead of Visual Studio, I got stuck at this point:

:>python setup.py -build -c mingw32 install
:running build
:running build_ext
:building 'cx_Oracle' extension
:D:\minGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Id:\orant\oci80\include
:-Id:\orant\rdbms80\demo -ID:\Python23\include -ID:\Python23\PC -c
:cx_Oracle.c -o build\temp.win32-2.3\Release\cx_oracle.o
:"-DBUILD_TIME="""June 04, 2004 16:42:10"""
:In file included from cx_Oracle.c:63:
:Environment.c: In function `Environment_New':
:Environment.c:78: warning: implicit declaration of function `OCIEnvCreate'
:[follows a bunch of declaration errors for anything that's named
:OCIwhatever]


According to the Oracle Docs, "OCIEnvCreate creates and initializes an
environment for OCI functions to work under".

So my uneducated guess is that this OCIEnvCreate function is not present in
Oracle 8.0.6, but I can't find anything in the docs that hints to it.


1. Is there a way around this OCIEnvCrete problem?

2. Is there an alternative to cx_Oracle that works out of the box with
Oracle 8.0.6? (tryed DCOracle2, but couldn't make it work with Python2.3
AND without Zope)

3. Should I give up cx_Oracle and stick with ODBC?

4. Should I give up python and stick with Access VBA? (sorry, bad joke)



Any insight would be helpful (even another forum where I could forward this
specific question).

Thanks in advance,
Rodrigo Daunaravicius

I had the same problem trying to connect to an Oracle 8.0.5 database.
The cx_Oracle binary was compiled for Oracle 8i/9i, and it didn't work
with the Oracle 8.0.5 OCI (Oracle Call Interface). Neither did the
source (I think it's designed to connect to an 8i/9i OCI, different from
an 8.0 OCI).


The solution (for me):

I installed an Oracle 8i client in another ORACLE_HOME in the same
Windows box, and modified the PATH environment variable to put the BIN
directory of the (new) Oracle 8i ORACLE_HOME before the BIN directory of
the (old) Oracle 8.0.5 ORACLE_HOME. So, when the cx_Oracle binary looks
for the OCI, it finds the Oracle8i installation and connects to the
database.

From your post, it's not clear to me if you have an Oracle 8.0.6 server
in your machine, or not. Maybe an Oracle server installation does not
like the Oracle 8i client installation and the PATH modification that I
suggest.

Hope this helps

Aurelio
 
D

David Fraser

Rodrigo said:
According to the Oracle Docs, "OCIEnvCreate creates and initializes an
environment for OCI functions to work under".

So my uneducated guess is that this OCIEnvCreate function is not present in
Oracle 8.0.6, but I can't find anything in the docs that hints to it.


1. Is there a way around this OCIEnvCrete problem?

From
http://www.csee.umbc.edu/help/oracle8/server.815/a67846/oci_func.htm#543147
OCIEnvCreate()

This call creates an environment for all the OCI calls using the modes specified by the user. This call should be invoked before any other OCI call and should be used instead of the OCIInitialize() and OCIEnvInit() calls. OCIInitialize() and OCIEnvInit() calls will be supported for backward compatibility.

If you really need to get it working with 8.0.x libraries, you could try
converting the call to OCIInitialize() and OCIEnvInit() calls.
You'll need to replace OCITerminate with OCIHandleFree.
In my experience these are the two main changes between 8.0.x and 8.1
You might find some help from the cx_Oracle authors, but the oracle docs
are fairly good.
Here is some code from a C++ database class that supports either
(tryimportOCIProc and importedOCIProc and importOCIProc are macros that
do dynamic function resolving, you should get the general idea)

tryimportOCIProc(OCIEnvCreate, sword, (OCIEnv **envp, ub4 mode, dvoid
*ctxp,
dvoid *(*malocfp)(dvoid *ctxp, size_t size),
dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr, size_t newsize),
void (*mfreefp)(dvoid *ctxp, dvoid *memptr),
size_t xtramem_sz, dvoid **usrmempp));

if (!importedOCIProc(OCIEnvCreate))
{
importOCIProc(OCIInitialize, sword, (ub4 mode, CONST dvoid *ctxp,
CONST dvoid *(*malocfp)(dvoid *ctxp, size_t size),
CONST dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr,size_t newsize),
CONST void (*mfreefp)(dvoid *ctxp,dvoid *memptr)));
importOCIProc(OCIEnvInit, sword, (OCIEnv **envhpp, ub4 mode,
size_t xtramemsz, dvoid **usrmempp));

if (envhp == 0)
{
OCIInitialize(OCI_THREADED, 0, 0, 0, 0);
OCIEnvInit(&envhp, OCI_DEFAULT, 100, &testmem);
}
// AfxMessageBox("Using OCI 8.0",MB_OK);
}
else
{
if (envhp == 0)
OCIEnvCreate(&envhp, OCI_THREADED, 0, 0, 0, 0, 0, 0);
}
 
R

Rodrigo Daunaravicius

If you really need to get it working with 8.0.x libraries, you could try
converting the call to OCIInitialize() and OCIEnvInit() calls.
You'll need to replace OCITerminate with OCIHandleFree.
In my experience these are the two main changes between 8.0.x and 8.1
You might find some help from the cx_Oracle authors, but the oracle docs
are fairly good.

Thanks, David. I successfully replaced the OCIEnvCreate() call, but still
had problems with OCILobCreateTemporary(), OCILobFreeTemporary(),
OCIUserCallbackRegister(), OCIUserCallbackGet(), OCI_UCBTYPE_ENTRY,
OCI_UCBTYPE_EXIT and OCI_UCBTYPE_REPLACE. This amount of patchwork from my
inexperienced hands would be asking for trouble, even if I could get it
compiled.
An 8i installation, as Aurelio suggested, is unfortunately not an option.
I'm now looking into ADO. I think it can fit the bill for my current
project, though I'd prefer to use the python DB API 2.0.

Rodrigo
 
D

David Fraser

Rodrigo said:
Thanks, David. I successfully replaced the OCIEnvCreate() call, but still
had problems with OCILobCreateTemporary(), OCILobFreeTemporary(),
OCIUserCallbackRegister(), OCIUserCallbackGet(), OCI_UCBTYPE_ENTRY,
OCI_UCBTYPE_EXIT and OCI_UCBTYPE_REPLACE. This amount of patchwork from my
inexperienced hands would be asking for trouble, even if I could get it
compiled.

Oh well, it was worth a try...
An 8i installation, as Aurelio suggested, is unfortunately not an option.
I'm now looking into ADO. I think it can fit the bill for my current
project, though I'd prefer to use the python DB API 2.0.

Aha! But you can... there are at least two DB API wrappers for ADO:
http://pyado.sourceforge.net/
http://adodbapi.sourceforge.net/

So your code remains DB-API compatible, and portable to other drivers,
but gets to use ADO and support any database supported by that...

David
 
?

=?ISO-8859-1?Q?Bernard_Delm=E9e?=

An 8i installation, as Aurelio suggested, is unfortunately not an option.

You still haven't told us why; are you running an 8.0.6 server
on that box? I reckon you could install a minimal more recent
oracle client, *not* put it on your global path, but simply stick
it at the beginning of your python script path *before* importing
cx_oracle.

Oracle instant client weights about 30Mb on windows:
http://otn.oracle.com/tech/oci/instantclient/instantclient.html
(warning: this probably requires an OTN registration)

HTH,

Bernard.
 
R

Rodrigo Daunaravicius

You still haven't told us why; are you running an 8.0.6 server
on that box? I reckon you could install a minimal more recent
oracle client, *not* put it on your global path, but simply stick
it at the beginning of your python script path *before* importing
cx_oracle.

Oracle instant client weights about 30Mb on windows:
http://otn.oracle.com/tech/oci/instantclient/instantclient.html
(warning: this probably requires an OTN registration)

HTH,

Bernard.

My only problem was licence. I wasn't aware of this Instant Client, but I'm
definitely giving it a try. Thanks Bernard.

Rodrigo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top