[gdal-dev] Oracle OCI connection in Python OGR

Eric Wolf ebwolf at gmail.com
Tue Feb 16 00:43:09 EST 2010


Thanks Ivan,

NLS_LANGUAGE = AMERCAN

Reading shapefile works (still).

Rather aggravating... I may try it on another system to see what I get.

-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 9:42 PM, Ivan Lucena <ivan.lucena at pmldnet.com>wrote:

> Eric,
>
> Sorry for my typo. I mean, "it was a good clue".
>
> I did a quit test using GDAL 1.8dev, the trunk version. I build the python
> wrapper myself by running "setup.py bdist_wininst" with Python 2.5.4. That
> generates "GDAL-1.7.0.win32-py2.5.exe".
>
> That is how it goes:
>
> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from osgeo import ogr
> >>> ds = ogr.Open("OCI:scott/tiger at orcl")
> >>> ly = ds.GetLayer(0)
> >>> ly.GetName()
> 'ROADS'
> >>>
>
> No problem here.
>
> I believe that you should use a GDAL/Python wrapper compatible (UNICODE)
> with the Python you have.
>
> By the way, what is the character set of your database?
>
> select * from NLS_DATABASE_PARAMETERS;
>
> There is also the NLS_LANG. NLS_LANG is set as a local environment variable
> on UNIX and is set in the registry on Windows.
>
> I just following that clue, but can you use ogr.Open() with a local file,
> like a shape file?
>
> Best regards,
>
> Ivan
>
>
>
>
> >  -------Original Message-------
> >  From: Eric Wolf <ebwolf at gmail.com>
> >  To: gdal-dev <gdal-dev at lists.osgeo.org>
> >  Subject: Re: [gdal-dev] Oracle OCI connection in Python OGR
> >  Sent: Feb 15 '10 17:47
> >
> >  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: [LINK: http://www.h4h.net/ebwolf.public.key.txt]
> >  http://www.h4h.net/ebwolf.public.key.txt
> >
> >
> >  On Mon, Feb 15, 2010 at 3:33 PM, Ivan <[LINK:
> >  mailto:ivan.lucena at pmldnet.com] 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: [LINK: http://www.h4h.net/ebwolf.public.key.txt]
> >  http://www.h4h.net/ebwolf.public.key.txt
> >
> >
> >  On Sun, Feb 14, 2010 at 12:45 PM, Abhay <[LINK:
> >  mailto:abhay.menon at gmail.com] abhay.menon at gmail.com <mailto:[LINK:
> >  mailto:abhay.menon at gmail.com] abhay.menon at gmail.com>> wrote:
> >
> >
> >     On Fri, Feb 12, 2010 at 11:32 PM, Eric Wolf <[LINK:
> >  mailto:ebwolf at gmail.com] ebwolf at gmail.com
> >
> >     <mailto:[LINK: mailto:ebwolf at gmail.com] 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: [LINK:
> >  http://www.h4h.net/ebwolf.public.key.txt]
> >  http://www.h4h.net/ebwolf.public.key.txt
> >
> >
> >         On Fri, Feb 12, 2010 at 6:56 AM, Abhay <[LINK:
> >  mailto:abhay.menon at gmail.com] abhay.menon at gmail.com
> >
> >         <mailto:[LINK: mailto:abhay.menon at gmail.com]
> >  abhay.menon at gmail.com>> wrote:
> >
> >
> >             On Fri, Feb 12, 2010 at 2:48 PM, Eric Wolf <[LINK:
> >  mailto:ebwolf at gmail.com] ebwolf at gmail.com
> >
> >
> >             <mailto:[LINK: mailto:ebwolf at gmail.com]
> >  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: [LINK:
> >  http://www.h4h.net/ebwolf.public.key.txt]
> >  http://www.h4h.net/ebwolf.public.key.txt
> >
> >                 _______________________________________________
> >                 gdal-dev mailing list
> >                 [LINK: mailto:gdal-dev at lists.osgeo.org]
> >  gdal-dev at lists.osgeo.org <mailto:[LINK: mailto:gdal-dev at lists.osgeo.org
> ]
> >  gdal-dev at lists.osgeo.org>
> >
> >                 [LINK:
> >  http://lists.osgeo.org/mailman/listinfo/gdal-dev]
> >  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 a
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100215/3f9c6c70/attachment-0001.html


More information about the gdal-dev mailing list