Is This Content Helpful?
How can we make this better? Please provide as much detail as possible.
Contact our Support Team
Connecting to SQL Server and making SQL queries can be incorporated into Python to aid common GIS geoprocessing tasks.
The procedures below describe how to connect to a SQL Server database and make SQL queries from Python.
Note: Since ArcGIS Desktop by default installs the 32-bit version of Python, install the 32-bit version of pyodbc.
con = pyodbc.connect('DRIVER={SQL Server};SERVER=Prod1\SQL2008R2;DATABASE=SDE;UID=sa;PWD=sa')
con = pyodbc.connect('Trusted_Connection=yes', driver = '{SQL Server}',server = ‘Prod1\SQL2008R2 ‘, database = ‘SDE')
cur = con.cursor()
querystring = "select * into ParcelsA from ParcelsB"
cur.execute(querystring) con.commit()
Last Published: 6/27/2019
Article ID: 000011656
Software: Legacy Products