Single Table Database #13297
-
I have a problem where I want to read, write, update, delete data records on a raspberry pi pico using Micropython. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
For an in-memory solution why not use a Python |
Beta Was this translation helpful? Give feedback.
-
What I did was I put this at the top of my main file: # my data dictionary
my_data_dict = OrderedDict([('Time','00:00'), ('Battery voltage', 26.5), ('PV current', 10.00), ('Load current', 4.00), ('Daily WH in', 0.00), ('Daily WH out', 0.00), ('State of charge', 90), ('Battery temperature', 20.00), ('Error', 20480)]) then passed it to Another thing I found was that I had to use Good luck! |
Beta Was this translation helpful? Give feedback.
-
I'd do something like this (reduced number of fields for ease of understanding): message_dict = {} # Globally available message dict
record = {"src_device": "", "dst_device": "", "time_stamp": ()} # Record template
def add_record(msg_no, src_device, dst_device, time_stamp):
record["src_device"] = src_device
record["dst_device"] = dst_device
record["time_stamp"] = time_stamp
message_dict[msg_no] = record.copy() # Make a copy of the populated template. This produces the following: >>> add_record(1, 'test', 'dest', (1,2,3))
>>> add_record(2, 'test_2', 'dest_2', (4,5,6))
>>> message_dict[1]
{'dst_device': 'dest', 'src_device': 'test', 'time_stamp': (1, 2, 3)}
>>> message_dict[2]
{'dst_device': 'dest_2', 'src_device': 'test_2', 'time_stamp': (4, 5, 6)}
>>> message_dict[1]["time_stamp"]
(1, 2, 3) Note that, if you want The purpose of |
Beta Was this translation helpful? Give feedback.
I'd do something like this (reduced number of fields for ease of understanding):
This produces the following: