This is my code of python in qgis from qgis documentation docs
uri = QgsDataSourceURI()
uri.setConnection("localhost","5432","gis_data","postgres","vajja")
uri.setDataSource("","poi_sv1","long","","lat")
vlayer = QgsVectorLayer(uri.uri(),"LayerName","postgres")
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
Error:
NOTICE: WARNING: there is no transaction in progress
Erroneous query: SELECT DISTINCT upper(geometrytype("long")),st_srid("long"),st_ndims("long") FROM "poidata"."poi_sv" returned 7 [ERROR: function geometrytype(double precision) does not exist 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.
invalid PostgreSQL layer
My datatypes are in text and double precision.
It tried both longitude and latitude in text and double precision but still it isn't working.
When I do debug I am getting error at vlayer line 4 from the above code
{}
that makes code formatting easy. As it stands you do not seem to be telling us what you are trying to do so I recommend using the edit button to try and make your question clearer by the inclusion of a question mark in its body. – PolyGeo♦ Aug 20 at 21:52