Esempio n. 1
0
 def setConnection(self, connection):
     self._connection = connection
     if isinstance(connection, str):
         self._database = GeoDB.from_name(connection)
     else:
         self._database = None
     self.refreshItems()
     self.widgetValueHasChanged.emit(self)
Esempio n. 2
0
 def setConnection(self, connection):
     self._connection = connection
     # when there is NO connection (yet), this get's called with a ''-connection
     if isinstance(connection, str) and connection != '':
         self._database = GeoDB.from_name(connection)
     else:
         self._database = None
     self.refreshItems()
     self.widgetValueHasChanged.emit(self)
Esempio n. 3
0
 def populateSchemas(self):
     if self.childCount() != 0:
         return
     geodb = GeoDB.from_name(self.connection)
     schemas = geodb.list_schemas()
     for oid, name, owner, perms in schemas:
         item = QTreeWidgetItem()
         item.setText(0, name)
         item.setIcon(0, self.schemaIcon)
         self.addChild(item)
Esempio n. 4
0
 def populateSchemas(self):
     if self.childCount() != 0:
         return
     geodb = GeoDB.from_name(self.connection)
     schemas = geodb.list_schemas()
     for oid, name, owner, perms in schemas:
         item = QTreeWidgetItem()
         item.setText(0, name)
         item.setIcon(0, self.schemaIcon)
         self.addChild(item)
Esempio n. 5
0
 def _db_rows(self, qgis_conn, select_sql):
     with tempfile.TemporaryFile() as fb, \
             io.TextIOWrapper(fb, encoding='utf-8', newline='') as f:
         if HAS_DB_PROCESSING_PARAMETER:
             with pg_conn(qgis_conn) as conn, \
                     conn.cursor() as cur:
                 pg_copy(cur, select_sql, f)
         else:
             db = GeoDB.from_name(qgis_conn)
             cur = db.con.cursor()
             pg_copy(cur, select_sql, f)
         f.seek(0)
         reader = csv.reader(f, delimiter='|', quotechar='"')
         yield from reader