is it possible to request the primary key value of an selected object in QGis?
My Layer is stored in a postgresql db. Loaded as wfs Layer in QGis
Python Code to select an object and return his attributes
[...]
def canvasPressEvent(self, event):
found_features = self.identify(event.x(), event.y(), [self.layer], QgsMapToolIdentify.TopDownAll)
for a in found_features:
print (a.mFeature.id(),a.mFeature.attributes())
Output
13 ['doc_1658386642','m4a',NULL, PyQt5.QtCore.QDateTime(2022,7,21,8,57,28,595),NULL] 24 ['doc_1672838277',NULL,'Dies ist eine Notiz',PyQt5.QtCore.QDateTime(2023,1,4,14,23,50,17),NULL]
Same Objects viewn in pgAdmin
| Id [PK] uuid | type var char | name var char | note var char | geom geometry | lastModified timestamp | orientation integer |
|---|---|---|---|---|---|---|
| "017ee6fe-4fb0-4761-a2f1-eb9e6b9f19ad" | "m4a" | "doc_1658386642" | "0101000020E6100000CCF6F48C0D3B22403A3CFF610BAA4A40" | "2022-07-21 06:57:28.595+00" | ||
| "2caaaa38-e140-4a7c-b3a6-8383c60fc07b" | "doc_1672838277" | "Dies ist eine Notiz" | "0101000020E61000000965EA8BEA3A2240AC84C562D6A94A40" | "2023-01-04 13:23:50.017701+00" |
I would like to get the id [PK, uuid] of these objects for example (017ee6fe-4fb0-4761-a2f1-eb9e6b9f19ad) - any suggestions? is it even possible?
source https://stackoverflow.com/questions/75339423/get-primary-key-value-from-object-in-qgis
Comments
Post a Comment