Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- host = self.dbhost
- port = self.dbport
- dbname = self.dbname
- username = self.dbuser
- password = self.dbpass
- t0 = time.time()
- ## Adds a PostGIS table to the map
- uri = QgsDataSourceUri()
- uri.setConnection(str(host), str(port), str(dbname), str(username), str(password))
- uri.setDataSource(str(schema), str(table), str(geom_col), filter_text, 'field_row_id')
- uri.setKeyColumn('field_row_id')
- uri.setSrid('4326')
- t1 = time.time()
- vlayer = QgsVectorLayer(uri.uri(), str(extra_name) + str(table), 'postgres')
- t2 = time.time()
- if not vlayer.isValid():
- QMessageBox.information(None, 'Error', 'Layer not loaded correctly, Connection:n' + str(uri.uri()))
- 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