I am a novice to Python and QGIS coding. I am facing an issue while showing the MySQL spatial data on QGIS canvas. Database connection details are below:
database name:- mysql
host :- localhost
port :- 3306
user :- root
password :- abcx
tablename:- Tablegis
I found a code on to connect the same:
uri="MySQL:mysql,host=localhost,port=3306,user=root,password=abcx|layername=Tablegis"
vlayer=QGSVectorLayer(uri, "Open_Table","ogr")
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
This code doesn't show any warning or error but nothing shows on my canvas. When I am printing the vlayer shows the object reference. Tried hard nothing worked for me.