QGIS PostGIS – Why Can’t PostGIS Layers Be Opened in QGIS?

postgisqgis

I've set up a table in PostGIS using OSM data (converted using osm2pgsql). I know this database is good, because I'm able to import it and work with it in TileMill, but whenever I try to interact with any of the layers in QGIS (1.8.0, OSX), the Add button is greyed out (even if I put in a query).

I've tested the connection and when I test my queries it shows that lots of rows were returned, so (again), the data's clearly thereā€”I just can't open it up.

CLARIFICATION: It's also worth noting that QGIS is able to see the database just fine. I can build queries and read out data in the Add PostGIS layer interface and everything comes back correctly. The only thing I can't do in the Add PostGIS Layer interface is add the layer.

CLARIFICATION 2 (from the comments): postgis_version returns 2.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1. The extensions active on the database are plpgsql (1.0), postgis (2.0.3), and postgis_topology (2.0.3). PostgreSQL and PostGIS were installed using Homebrew.

The table does (now) have a primary key, but QGIS doesn't appear to find it.

Best Answer

The problem, as it turns out, was that I had not named the connection.

Related Question