MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / _format_event

Method _format_event

opcua/server/history_sql.py:284–308  ·  view source on GitHub ↗

Convert an event object triggered by the subscription into ordered lists for the SQL insert string Args: event: The event returned by the subscription Returns: List of event fields (SQL column names), List of '?' placeholders, Tuple of variant binaries

(self, event)

Source from the content-addressed store, hash-verified

282 return start_time, end_time, order, limit
283
284 def _format_event(self, event):
285 """
286 Convert an event object triggered by the subscription into ordered lists for the SQL insert string
287
288 Args:
289 event: The event returned by the subscription
290
291 Returns: List of event fields (SQL column names), List of '?' placeholders, Tuple of variant binaries
292
293 """
294 placeholders = []
295 ev_variant_binaries = []
296
297 ev_variant_dict = event.get_event_props_as_fields_dict()
298 names = list(ev_variant_dict.keys())
299 names.sort() # sort alphabetically since dict is not sorted
300
301 # split dict into two synchronized lists which will be converted to SQL strings
302 # note that the variants are converted to binary objects for storing in SQL BLOB format
303 for name in names:
304 variant = ev_variant_dict[name]
305 placeholders.append('?')
306 ev_variant_binaries.append(sqlite3.Binary(variant_to_binary(variant)))
307
308 return self._list_to_sql_str(names), self._list_to_sql_str(placeholders, False), tuple(ev_variant_binaries)
309
310 def _get_event_columns(self, ev_fields):
311 fields = []

Callers 1

save_eventMethod · 0.95

Calls 4

_list_to_sql_strMethod · 0.95
variant_to_binaryFunction · 0.90
keysMethod · 0.80

Tested by

no test coverage detected