sql="select long,lat from poidata.poi_ca from where city LIKE'%unnyvale'"
uri = QgsDataSourceURI()uri.setConnection("localhost","5432","gis_data","postgres","vajja")uri.setDataSource("",sql,"long","","lat") vlayer =QgsVectorLayer(uri.uri(),"LayerName","postgres")QgsMapLayerRegistry.instance().addMapLayer(vlayer)
Error: Unable to access the "select long,lat from poidata.poi_ca from where city LIKE '%unnyvale'" relation. The error message from the database was: ERROR: relation "select long,lat from poidata.poi_ca from where city LIKE '%unny" does not exist LINE 1: SELECT * FROM "select long,lat from poidata.poi_ca from wher... ^ . SQL: SELECT * FROM "select long,lat from poidata.poi_ca from where city LIKE '%unnyvale'"
uri = QgsDataSourceURI()uri.setConnection("localhost","5432","gis_data","postgres","vajja")uri.setDataSource("poidata","poi_sv","long","","lat")
vlayer =QgsVectorLayer(uri.uri(),"connect","postgres")QgsMapLayerRegistry.instance().addMapLayer(vlayer)
Error:LINE 1: SELECT DISTINCT upper(geometrytype("long")),st_srid("long"),... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
sql="gis_data.poidata.poi_sv"
uri = QgsDataSourceURI()uri.setConnection("localhost","5432","gis_data","postgres","vajja")uri.setDataSource("",sql,"long","","lat")
vlayer =QgsVectorLayer(uri.uri(),"LayerName","postgres")QgsMapLayerRegistry.instance().addMapLayer(vlayer)
Error:Unable to access the "gis_data.poidata.poi_sv" relation. The error message from the database was: ERROR: relation "gis_data.poidata.poi_sv" does not exist LINE 1: SELECT * FROM "gis_data.poidata.poi_sv" LIMIT