I'm using PyScripter to explore PyQGIS API because of it's very handy auto-completion function.
I've managed to get a handle on a PostGis vector layer by:
>>> from qgis.core import * >>> uri = QgsDataSourceURI() >>> uri.setConnection("<some URL>","5432","<DB name>","<user>","<password>") >>> uri.setDataSource("public","<table name>","<geometry column name>") >>> vLayer=QgsVectorLayer(uri.uri(),"<layer name>","postgres") >>> vLayer <qgis.core.QgsVectorLayer object at 0x052B4D68>
So far so good. My next step is to explore the layer's dataProvider.
>>> vLayer.dataProvider() >>>
Why doesn't vLayer.dataProvider() yield anything, like in QGIS Python Console?
Do I need to initialize vLayer more?