Advertisement
Guest User

Untitled

a guest
Dec 15th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. host='localhost'
  2. port="5432"
  3. db='rob'
  4. user='rob'
  5. password='password'
  6.  
  7. filter = "name = 'M5'"
  8. uri = QgsDataSourceURI()
  9. uri.setConnection(host, port, db, user, password)
  10. uri.setDataSource("public", "dft_major_roads", "geom", filter ,"gid")
  11. print uri.uri()
  12. vlayer = QgsVectorLayer(uri.uri(), "M5", "postgres")
  13. QgsMapLayerRegistry.instance().addMapLayer(vlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement