Browse Source

Add binary option to nilmdb.stream_insert

tags/nilmdb-1.5.0
Jim Paris 11 years ago
parent
commit
b362fd37f6
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      nilmdb/server/nilmdb.py

+ 6
- 2
nilmdb/server/nilmdb.py View File

@@ -475,12 +475,16 @@ class NilmDB(object):
con.execute("DELETE FROM ranges WHERE stream_id=?", (stream_id,))
con.execute("DELETE FROM streams WHERE id=?", (stream_id,))

def stream_insert(self, path, start, end, data):
def stream_insert(self, path, start, end, data, binary = False):
"""Insert new data into the database.
path: Path at which to add the data
start: Starting timestamp
end: Ending timestamp
data: Textual data, formatted according to the layout of path

'binary', if True, means that 'data' is raw binary:
little-endian, matching the current table's layout,
including the int64 timestamp.
"""
# First check for basic overlap using timestamp info given.
stream_id = self._stream_id(path)
@@ -494,7 +498,7 @@ class NilmDB(object):
# there are any parse errors.
table = self.data.getnode(path)
row_start = table.nrows
table.append_data(data, start, end)
table.append_data(data, start, end, binary)
row_end = table.nrows

# Insert the record into the sql database.


Loading…
Cancel
Save