Error while connecting qgis with postgres?

المشرف العام

Administrator
طاقم الإدارة
  1. 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'"

  1. 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.

  1. 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

Sources:
https://georepublic.info/en/blog/2013/joining-tables-with-sql-using-pyqgis/http://docs.qgis.org/2.8/en/docs/pyqgis_developer_cookbook/loadlayer.html

I tried both the above from differnt source but still I get an erroe



أكثر...
 
أعلى