I have a python geoprocessing that takes a lot of time. The geoprocessing calculates geometries using points, polygons, buffers, and cursors.
Jake:3 more questions1.) Do I need a special driver for an Oracle connection with pyodbc?2.) What is the syntax difference for Oracle in the line cnxn = pyodbc.connect('Driver={SQL Server Native Client 11.0};UID=gis;PWD=gis;SERVER=sdeserver;DATABASE=db;')?an example would be great3.) What is the syntax for getting the number of records counted so I know the python script actually selected records?Thank you
SELECT COUNT(*) FROM table_name;
Jake:Can you post the code for the quick tests you did to compare ArcSDESQLExecute function using the arcpy library vs the pyodbc library?
import pyodbc, time, arcpy startTime = time.clock() sde_conn = arcpy.ArcSDESQLExecute(r"Database Connections\SQLSERVER.sde") sql = "select OBJECTID, FEATURE, P_ST_NO, P_ST_NAME, P_ST_TYPE, P_CITY, P_Z_1 from AddressPoints" sde_return = sde_conn.execute(sql) endTime = time.clock() elapsedTime = endTime - startTime print elapsedTime startTime = time.clock() cnxn = pyodbc.connect('Driver={SQL Server Native Client 11.0};UID=gis;PWD=gis;SERVER=sdeserver;DATABASE=db;') cursor=cnxn.cursor() cursor.execute("select OBJECTID, FEATURE, P_ST_NO, P_ST_NAME, P_ST_TYPE, P_CITY, P_Z_1 from AddressPoints") rows = cursor.fetchall() cursor.close() cnxn.close() endTime = time.clock() elapsedTime = endTime - startTime print elapsedTime
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.