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/ti...@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.me...@gmail.com> wrote: > > > On Fri, Feb 12, 2010 at 2:48 PM, Eric Wolf <ebw...@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@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@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev