Is This Content Helpful?
We're glad to know this article was helpful.
Connecting to PostgreSQL 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 a PostgreSQL database and run SQL queries from a Python script.
connection = psycopg2.connect(host='prod', database='sde', user='sde', password='sde')
cursor = connection.cursor()
cursor.execute('select * from PARCELS WHERE OBJECTID < 70000')
for query in cursor: