installing cx_Oracle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rodrigo Daunaravicius

    installing cx_Oracle

    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\g cc.exe -mno-cygwin -mdll -O -Wall -Id:\orant\oci80 \include
    :-Id:\orant\rdbms 80\demo -ID:\Python23\in clude -ID:\Python23\PC -c
    :cx_Oracle.c -o build\temp.win3 2-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_Ne w':
    :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, "OCIEnvCrea te 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
  • David Fraser

    #2
    Re: installing cx_Oracle

    Rodrigo Daunaravicius wrote:
    [color=blue]
    > 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)[/color]

    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

    Comment

    • Aurelio Martin

      #3
      Re: installing cx_Oracle


      Rodrigo Daunaravicius wrote:[color=blue]
      > 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\g cc.exe -mno-cygwin -mdll -O -Wall -Id:\orant\oci80 \include
      > :-Id:\orant\rdbms 80\demo -ID:\Python23\in clude -ID:\Python23\PC -c
      > :cx_Oracle.c -o build\temp.win3 2-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_Ne w':
      > :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, "OCIEnvCrea te 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[/color]

      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

      Comment

      • David Fraser

        #4
        Re: installing cx_Oracle

        Rodrigo Daunaravicius wrote:[color=blue]
        > According to the Oracle Docs, "OCIEnvCrea te 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?[/color]

        From
        http://www.csee.umbc.edu/help/oracle...unc.htm#543147[color=blue]
        > 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.
        >[/color]

        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
        (tryimportOCIPr oc and importedOCIProc and importOCIProc are macros that
        do dynamic function resolving, you should get the general idea)

        tryimportOCIPro c(OCIEnvCreate, sword, (OCIEnv **envp, ub4 mode, dvoid
        *ctxp,
        dvoid *(*malocfp)(dvo id *ctxp, size_t size),
        dvoid *(*ralocfp)(dvo id *ctxp, dvoid *memptr, size_t newsize),
        void (*mfreefp)(dvoi d *ctxp, dvoid *memptr),
        size_t xtramem_sz, dvoid **usrmempp));

        if (!importedOCIPr oc(OCIEnvCreate ))
        {
        importOCIProc(O CIInitialize, sword, (ub4 mode, CONST dvoid *ctxp,
        CONST dvoid *(*malocfp)(dvo id *ctxp, size_t size),
        CONST dvoid *(*ralocfp)(dvo id *ctxp, dvoid *memptr,size_t newsize),
        CONST void (*mfreefp)(dvoi d *ctxp,dvoid *memptr)));
        importOCIProc(O CIEnvInit, sword, (OCIEnv **envhpp, ub4 mode,
        size_t xtramemsz, dvoid **usrmempp));

        if (envhp == 0)
        {
        OCIInitialize(O CI_THREADED, 0, 0, 0, 0);
        OCIEnvInit(&env hp, OCI_DEFAULT, 100, &testmem);
        }
        // AfxMessageBox(" Using OCI 8.0",MB_OK);
        }
        else
        {
        if (envhp == 0)
        OCIEnvCreate(&e nvhp, OCI_THREADED, 0, 0, 0, 0, 0, 0);
        }

        Comment

        • Rodrigo Daunaravicius

          #5
          Re: installing cx_Oracle


          On Fri, 04 Jun 2004 22:11:06 +0200, David Fraser wrote:
          [color=blue]
          > 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.[/color]

          Thanks, David. I successfully replaced the OCIEnvCreate() call, but still
          had problems with OCILobCreateTem porary(), OCILobFreeTempo rary(),
          OCIUserCallback Register(), OCIUserCallback Get(), OCI_UCBTYPE_ENT RY,
          OCI_UCBTYPE_EXI T and OCI_UCBTYPE_REP LACE. 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

          Comment

          • David Fraser

            #6
            Re: installing cx_Oracle

            Rodrigo Daunaravicius wrote:[color=blue]
            > On Fri, 04 Jun 2004 22:11:06 +0200, David Fraser wrote:
            >
            >[color=green]
            >>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.[/color]
            >
            >
            > Thanks, David. I successfully replaced the OCIEnvCreate() call, but still
            > had problems with OCILobCreateTem porary(), OCILobFreeTempo rary(),
            > OCIUserCallback Register(), OCIUserCallback Get(), OCI_UCBTYPE_ENT RY,
            > OCI_UCBTYPE_EXI T and OCI_UCBTYPE_REP LACE. This amount of patchwork from my
            > inexperienced hands would be asking for trouble, even if I could get it
            > compiled.[/color]

            Oh well, it was worth a try...
            [color=blue]
            > 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.[/color]

            Aha! But you can... there are at least two DB API wrappers for ADO:



            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

            Comment

            • Bernard Delmée

              #7
              Re: installing cx_Oracle

              > 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:
              Access cloud trials and software downloads for Oracle applications, middleware, database, Java, developer tools, and more.

              (warning: this probably requires an OTN registration)

              HTH,

              Bernard.

              Comment

              • Rodrigo Daunaravicius

                #8
                Re: installing cx_Oracle

                On Tue, 08 Jun 2004 12:42:00 +0200, David Fraser wrote:
                [color=blue]
                > Aha! But you can... there are at least two DB API wrappers for ADO:
                > http://pyado.sourceforge.net/
                > http://adodbapi.sourceforge.net/[/color]

                Yes! I imagined such a wrapper might exist and found adodbapi. It seems
                quite satisfactory. I'll have a look at pyado too. Thanks again, David.

                Rodrigo

                Comment

                • Rodrigo Daunaravicius

                  #9
                  Re: installing cx_Oracle

                  On Tue, 08 Jun 2004 21:02:45 +0200, Bernard Delmée wrote:
                  [color=blue][color=green]
                  >> An 8i installation, as Aurelio suggested, is unfortunately not an option.[/color]
                  >
                  > 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/insta...antclient.html
                  > (warning: this probably requires an OTN registration)
                  >
                  > HTH,
                  >
                  > Bernard.[/color]

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

                  Rodrigo

                  Comment

                  Working...