[gdal-dev] Oracle OCI connection in Python OGR

Eric Wolf ebwolf at gmail.com
Mon Feb 15 17:47:30 EST 2010


I'm beginning to think something is wrong at my end. I just installed Python
2.5, GDAL 1.5 and cx_Oracle for Python 2.5. I'm still getting the same
behavior. cx_Oracle works, OGR doesn't.

Is the clue in my last email? I mean, the Unicode version of cx_Oracle
didn't work but the non-Unicode version did work. Is the OGR OCI driver
compiled for Unicode?

-Eric

-=--=---=----=----=---=--=-=--=---=----=---=--=-=-
Eric B. Wolf                    New! 720-334-7734
USGS Geographer
Center of Excellence in GIScience
PhD Student
CU-Boulder - Geography

GPG Public Key: http://www.h4h.net/ebwolf.public.key.txt


On Mon, Feb 15, 2010 at 3:33 PM, Ivan <ivan.lucena at pmldnet.com> wrote:

> Eric,
>
>
> Eric Wolf wrote:
>
>> I'm running Oracle 11g on the same machine as the Python script.
>>
>> I did test cx_Oracle and found that it wasn't working. I was using the
>> Unicode cx_Oracle 5.0.3. Switching to the non-Unicode cx_Oracle got it
>> working. But OGR is still not connecting.
>>
>> Does OGR rely on cx_Oracle?
>>
>
> No it doesn't but I was a good to clue.
>
>
>
>> I think I'll try regressing to an older version of GDAL and see if it
>> works.
>>
>
> I running GDAL/OGR/Python/OCI on OpenSUSE and it works just fine. I am
> going to test on Windows.
>
> Regards,
>
> Ivan
>
>
>> -Eric
>>
>> -=--=---=----=----=---=--=-=--=---=----=---=--=-=-
>> Eric B. Wolf                    New! 720-334-7734
>> USGS Geographer
>> Center of Excellence in GIScience
>> PhD Student
>> CU-Boulder - Geography
>>
>> GPG Public Key: http://www.h4h.net/ebwolf.public.key.txt
>>
>>
>> On Sun, Feb 14, 2010 at 12:45 PM, Abhay <abhay.menon at gmail.com <mailto:
>> abhay.menon at gmail.com>> wrote:
>>
>>
>>
>>    On Fri, Feb 12, 2010 at 11:32 PM, Eric Wolf <ebwolf at gmail.com
>>    <mailto:ebwolf at gmail.com>> wrote:
>>
>>        Thanks for the replies. Sorry I didn't give more details on the
>>        environment.
>>
>>        I am running on Windows, at the command line, both ogr2ogr and
>>        the python script.
>>
>>        Created an environment variable for ORACLE_SID=ORCL
>>
>>        I double-checked my OCI string by using sqlplus to connect:
>>
>>            sqlplus scott/tiger at orcl
>>
>>        This works fine. I changed the script to use that in the call to
>>        ogr.Open(). No luck.
>>
>>        I imported gdal and sprinkled print 'Error:',
>>        gdal.GetLastErrorMsg() in my exception handlers. I got:
>>
>>            Unable to open Oracle connection None
>>            Error:
>>
>>        Still no dice. If I take the same script and modify the
>>        GetDriverByName and Open to use a shapefile, it works perfectly.
>>
>>        -Eric
>>
>>
>>
>>        -=--=---=----=----=---=--=-=--=---=----=---=--=-=-
>>        Eric B. Wolf                    New! 720-334-7734
>>        USGS Geographer
>>        Center of Excellence in GIScience
>>        PhD Student
>>        CU-Boulder - Geography
>>
>>        GPG Public Key: http://www.h4h.net/ebwolf.public.key.txt
>>
>>
>>        On Fri, Feb 12, 2010 at 6:56 AM, Abhay <abhay.menon at gmail.com
>>        <mailto:abhay.menon at gmail.com>> wrote:
>>
>>
>>
>>            On Fri, Feb 12, 2010 at 2:48 PM, Eric Wolf <ebwolf at gmail.com
>>            <mailto:ebwolf at gmail.com>> wrote:
>>
>>                I'm using GDAL/OGR 1.6.1 with ActivePython 2.6.4-10 and
>>                cx_Oracle-5.0.3-11g. I am trying to connect to an Oracle
>>                11g instance.
>>
>>                This works:
>>
>>                    ogr2ogr -f "KML" emp.kml OCI:scott/tiger "EMP"
>>
>>                What am I doing wrong. This fails, ds is None:
>>
>>                from osgeo import ogr
>>
>>                try:
>>                    d = ogr.GetDriverByName('OCI')
>>                except:
>>                    print "Unable to GetDriverByName"
>>                    quit()
>>
>>                ds = None
>>
>>                try:
>>                    ds = ogr.Open('OCI:scott/tiger')
>>                except:
>>                    print "Unable to open OCI connection"
>>                    quit()
>>
>>                if ds is None:
>>                    print "Unable to open Oracle connection", ds
>>                    quit()
>>
>>                lyr = ds.GetLayerByName('EMP')
>>                number = lyr.GetFeatureCount()
>>
>>                print "Features: " + str(number)
>>
>>
>>
>>
>>                -=--=---=----=----=---=--=-=--=---=----=---=--=-=-
>>                Eric B. Wolf                    New! 720-334-7734
>>                USGS Geographer
>>                Center of Excellence in GIScience
>>                PhD Student
>>                CU-Boulder - Geography
>>
>>                GPG Public Key: http://www.h4h.net/ebwolf.public.key.txt
>>
>>                _______________________________________________
>>                gdal-dev mailing list
>>                gdal-dev at lists.osgeo.org <mailto:gdal-dev at lists.osgeo.org>
>>
>>                http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>>
>>            Hi Eric,
>>
>>            Form your mail it not clear what is cause of the problem.
>>
>>            There 2 scenario here
>>            1) you are on a remote machine form where your trying to
>>            connect oracle server machine:
>>
>>            a) Have you installed any Oracle Client in your system.
>>            Considering that you are using the complete oracle client
>>            installation you can use the following  :
>>  OCI:scott/tiger@<Tnsname entry for eg. ORCL>
>>
>>            b) if you are trying out with Instant client for 11g you
>>            should try either of the following
>>
>>            OCI:scott/tiger@//localhost/<your ORACLE SERVICE IDENTIFIER
>>            for eg ORCL>.
>>
>>            2) you are on the oracle server machine where
>>            you must set the oracle SID. like the following            on
>> windows            SET ORACLE_SID=ORCL
>>            or
>>            on *nix
>>            export ORACLE_SID=ORCL
>>
>>            then try your implementation or use methods stated in 1)
>>
>>
>>
>>            Rgds.
>>
>>            Abhay.
>>
>>
>>
>>        _______________________________________________
>>        gdal-dev mailing list
>>        gdal-dev at lists.osgeo.org <mailto:gdal-dev at lists.osgeo.org>
>>
>>        http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>>
>>    Hi Eric,
>>
>>    What I still did not get is whether your running Oracle Server 11g
>>    on the same machine on which your developing.
>>    Also have you tried connecting the same using "cx_Oracle.Connection"
>>    whether this connect string is working.
>>
>>    Are you using gdal-1.6.1-py2.6-win32.egg install with Python or
>>    build your on using SWIG python implementation.
>>
>>    Interestingly, what I found is that in gdal-1.6.1-py2.5-win32.egg
>>    which install using easy_install seem not work with OCI driver as
>>    way it should. But connection string using cx_Oracle is working. So
>>    it seem gdal-1.6.1-py*-win32.egg is broken for OCI plugin or
>>    probably it must be some setup I must have overlooked will setup, if
>>    someone else is working with same setup could help on this or Howard
>>    could comment on this.
>>    I have build my own egg using latest repo of gdal build and is
>>    working. If you need I can share the same egg file (for python 2.6)
>>    or wait for Howard to compile for the latest build of GDAL-1.7 for
>>    python officially as you would need gdalwin32-17 for this along with
>>    OCI build plugin.
>>
>>    Rgds.
>>
>>    Abhay.
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100215/8685ecd3/attachment.html


More information about the gdal-dev mailing list