# PostgreSQL equivalent of ArcPy search cursor

**URL:** <https://forums.percona.com/t/postgresql-equivalent-of-arcpy-search-cursor/8285>\
**Category:** PostgreSQL General Discussion\
**Created:** [November 19, 2020, 4:57am UTC](https://forums.percona.com/t/postgresql-equivalent-of-arcpy-search-cursor/8285 "2020-11-19T04:57:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![soumyarani](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@soumyarani](https://forums.percona.com/u/soumyarani)\
**Post date:** [November 19, 2020, 4:57am UTC](https://forums.percona.com/t/postgresql-equivalent-of-arcpy-search-cursor/8285/1 "2020-11-19T04:57:18Z")

</div>

Does anyone know of an equivalent to ArcPy’s search cursor in PostgreSQL?

I’ve moved from using Arc to PostGIS/QGIS for the first time and have a task that would have been perfect for search cursor but have no idea if there is/what the equivalent would be. If anyone knows [postgreSQL](https://hkrtrainings.com/postgresql-training)equivalents for update cursor too that would be a huge help too as I’m sure I’ll find I’m missing using that too soon.

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [November 23, 2020, 9:55am UTC](https://forums.percona.com/t/postgresql-equivalent-of-arcpy-search-cursor/8285/2 "2020-11-23T09:55:23Z")

</div>

Hi,

Reviewing the Search Cursor syntax:

```auto
SearchCursor (dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields})

```

[https://pro.arcgis.com/en/pro-app/arcpy/functions/searchcursor.htm](https://pro.arcgis.com/en/pro-app/arcpy/functions/searchcursor.htm)

It sounds like what you’re asking is really how to compose an SQL SELECT statement using PostGIS. If that’s the case and if you haven’t already done so, I’d suggest you review the excellent SQL examples in the PostGIS documentation:

[8. Simple SQL Exercises — Introduction to PostGIS](https://postgis.net/workshops/postgis-intro/simple_sql_exercises.html#)

And of course the postgres documentation describing the SELECT statement in detail:

[SELECT](https://www.postgresql.org/docs/12/sql-select.html)

---

<div class="post-metadata">

**Author:** ![Jobin\_Augustine](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jobin_augustine/32/1275_2.png) [@Jobin\_Augustine](https://forums.percona.com/u/Jobin_Augustine)\
**Post date:** [November 23, 2020, 7:18pm UTC](https://forums.percona.com/t/postgresql-equivalent-of-arcpy-search-cursor/8285/3 "2020-11-23T19:18:32Z")

</div>

1. Since PostgreSQL is a database system, with full fledged standard SQL support with Procedural language support. you can consider mainly 2 things.

The cursors offered by plpgsql language. which is the default language offered by PostgreSQL , Please refer : [https://www.postgresql.org/docs/current/plpgsql-cursors.html](https://www.postgresql.org/docs/current/plpgsql-cursors.html)

1. for more details. You may use other languages including Python using PL/Python extension.

Hope this helps

Jobin.
