Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
GraysonBellamy committed Jun 6, 2024
1 parent f0c8ea3 commit 908e83e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pyalicat/daq.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ def __init__(self, Daq, qualities, rate, database) -> None:
self.qout = None
return

def _key_func(self, x):
if x == "Request Sent":
return chr(0)
if x == "Response Received":
return chr(1)
if x.lower() == "unit_id":
return chr(2)
return x

async def create_table(self, dict, conn):
"""Creates a table in the database and adds columns for each key in the dictionary.
Expand All @@ -259,7 +268,8 @@ async def create_table(self, dict, conn):
"CREATE TABLE IF NOT EXISTS alicat (Time timestamp, Device text, PRIMARY KEY (Time, Device))"
)
)
for key in dict:
keys = sorted(dict.keys(), key=self._key_func)
for key in keys:
data_type = "text"
if key == "Request Sent" or key == "Response Received":
data_type = "timestamp"
Expand Down

0 comments on commit 908e83e

Please sign in to comment.