def add(self, uuid, tstamp, values):
"""Add an event in TrailDB.
uuid -- UUID of this event.
tstamp -- Timestamp of this event (datetime or integer).
values -- value of each field.
"""
if isinstance(tstamp, datetime):
tstamp = int(time.mktime(tstamp.timetuple()))
n = len(self.ofields)
value_array = (c_char_p * n)(*values)
value_lengths = (c_uint64 * n)(*[len(v) for v in values])
f = lib.tdb_cons_add(self._cons, uuid_raw(uuid), tstamp, value_array,
value_lengths)
if f:
raise TrailDBError("Too many values: %s" % values[f])
评论列表
文章目录