Access PostGIS functions in PyCharm Database Navigator

1k views Asked by At

I'm trying to write scripts that use PostGIS functions using the PyCharm Database Navigator.

PostGIS and PostgreSQL were installed using Homebrew on Mac.

The debugger does not recognize any functions that are loaded as part of the PostGIS extensions for PostgreSQL and raises errors when trying to run a script. Creating a simple table with a geometry data type fails, whereas the same command executes in PSQL.

Do I need to do any special configuration of the database connection?

2

There are 2 answers

0
thenaturalist On

Just ran into exactly this thing in PyCharm 2016.3.1. This JetBrains Support article brought the solution: If you're working in a schema other than public, you need to add public to the search path of the query as the PostGIS types are stored there.

Doing this allowed me to work with formulas and geography types.

0
Eugene Yaremenko On

Came across precisely the same issue today (postgis queries work in psql but fail in the PyCharm DB console). Looks like it's a bug in PyCharm 5 - upgrading to PyCharm 2016 fixed the issue. There is a related bug in JetBrains' issue tracker failed against IntelliJ Idea of the same generation as PyCharm 5.