domingo, 30 de agosto de 2015

Connecting to Oracle database on a network in python


Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required. 
http://gis.stackexchange.com

There is lots of information out there on how to do this, unfortunately, it all looks like Greek to me.

I need a connection to a DB so I can add and use tables and featureclasses contained within it. I have tried calling import cx_oracle in python win 32 build 218 but I get the response no module named cx_oracle.
I have tried searching this out (again Greek) and I assume that i need to install a version of it. I have not done this before so do not know which version, where to get it, where to install it, and how to then access it in python. 

We use Toad for Oracle version 11.0.0.116. Oracle version 11.2 I think.

UPDATE:

I was able to get this to work using the arccatalog location of the mapped SDE as mentioned below. However, this is going to be machine specific and I will need, in the future, to make this interchangeable. I was playing around at making my own SDE connection using arcpy CreateArcSDEConnectionFile_management but I cannot get the connection to work.


import arcpy, cx_Oracle

#con = cx_Oracle.connect('p747/p747.tfc@ORATFC01')
#print con.version
#con.close()


# Set variables
folderName = r"c:\connectionFiles"
fileName = "oratfc01.sde"
serverName = "ORATFC01"
serviceName = "ORATFC01"
databaseName = "p747"
authType = "DATABASE_AUTH"
username = "p747"
password = "p747.abc"
saveUserInfo = "SAVE_USERNAME"
versionName = "SDE.DEFAULT"
saveVersionInfo = "SAVE_VERSION"

# Process: Use the CreateArcSDEConnectionFile function
arcpy.CreateArcSDEConnectionFile_management (folderName,
                                             fileName,
                                             serverName,
                                             serviceName,
                                             databaseName,
                                             authType,
                                             username,
                                             password,
                                             saveUserInfo,
                                             versionName,
                                             saveVersionInfo)

No hay comentarios:

Publicar un comentario

Te agradezco tus comentarios. Te esperamos de vuelta.

Todos los Sábados a las 8:00PM

Optimismo para una vida Mejor

Optimismo para una vida Mejor
Noticias buenas que comentar