QGIS: How to solver issues to import view layers from sql

If you want to add to QGIS sql sentences, an easy way is to create views.

You only need to convert your sql sentence like:
select geom from links

to

create or replace view
v_links as

select geom from links

But, you probably see the following error:


Layer is not valid: The layer dbname='' host=0.0.0.0 port=5432 user='' password='' sslmode=disable key='""' type=Point table="public"."v_links" (point) sql= is not a valid layer and can not be added to the map. Reason: 

This issue is because an index doesn't exist for data
To solve it, just create an index as follows:

create or replace view
v_links as

select row_number() OVER (order by geom), geom from links

Enjoy it!


Comments

Popular posts from this blog

How to fix Android when developer options are not available for this user

Exception: Could not find a default OpenFlow controller in Mininet

v4l2: open /dev/video0: Permission denied