Guest User

Untitled

a guest
Nov 10th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. host = self.dbhost
  2. port = self.dbport
  3. dbname = self.dbname
  4. username = self.dbuser
  5. password = self.dbpass
  6. t0 = time.time()
  7. ## Adds a PostGIS table to the map
  8. uri = QgsDataSourceUri()
  9. uri.setConnection(str(host), str(port), str(dbname), str(username), str(password))
  10. uri.setDataSource(str(schema), str(table), str(geom_col), filter_text, 'field_row_id')
  11. uri.setKeyColumn('field_row_id')
  12. uri.setSrid('4326')
  13. t1 = time.time()
  14. vlayer = QgsVectorLayer(uri.uri(), str(extra_name) + str(table), 'postgres')
  15. t2 = time.time()
  16. if not vlayer.isValid():
  17. QMessageBox.information(None, 'Error', 'Layer not loaded correctly, Connection:n' + str(uri.uri()))
  18. print('DBfunc: setting uri con {u} s, creating layer from uri {s}, checking it {t1}'.format(u=round(t1-t0,3),s=round(t2-t1,3),t1=round(time.time()-t2,2)))
Add Comment
Please, Sign In to add comment