HowTo:  Connect and run SQL queries to an Oracle database from Python

相关信息
Article ID: 40598
Software:
ArcSDE 10, 10.1
ArcGIS - ArcEditor 10
ArcGIS - ArcInfo 10
ArcGIS - ArcView 10
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
ArcGIS for Desktop Basic 10.1
Platforms:
Windows Server 2008, Windows 7
RHEL 4, 5, 6

问题描述
Connecting to Oracle databases from Python provides the ability to run essential SQL queries that can be utilized in geoprocessing tasks.

Instructions provided describe how to connect to an Oracle database and run SQL queries from a Python script.
已邀请:

易智瑞技术支持

赞同来自:

解决方案
  1. Download and install the appropriate cx_Oracle module for the installed Python release (for example, Python 2.6, 2.7, etc.): http://cx-oracle.sourceforge.net/
  2. Import the module in the Python script: import cx_Oracle
  3. Make a connection to an Oracle database by passing in the appropriate user/password to the following connection string: connection = cx_Oracle.connect('sde/sde@orcl')
  4. Define a parameter to access the cursor method: cursor = connection.cursor()
  5. Create a query string: querystring = "select * from Parcels"
  6. Pass the query string to the cursor method: cursor.execute(querystring)


创建及修改时间
Created: 10/5/2012

Last Modified: 7/12/2013
原文链接
http://support.esri.com/en/kno ... 40598

要回复问题请先登录注册