Python Forum
Options for retaining persistent data?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Options for retaining persistent data?
#1
Other than using a small text file and updating it with data when variables change value, what mechanisms exist to retain data between system reboots?

on a raspberry pi-z0 i have a cronned job pinging for a wifi connection and rebooting the system on failure,
However now i want to run a small python script to respond to mqtt messages.


As the script is intended to raise alarms under numerous conditions a number of which reference the previously received payload its time of arrival and contents, or lack of.

And in order to avoid raising false alarms keeping a record of the last payload and its time of arrival that will survive a system reboot and restart of the script as a python newbie i am considering a simple text file update and check for existence/read on startup.

But I was wondering if there was a more elegant built in feature or library i could employ instead? or have i wasted a hour or so googling the wrong search terms completely??
Reply
#2
persistent data is any database. Whether its a text file, json, or MySQL. For something simple like this i would just do json. Its human readable, as well as more adaptable than a text file if you want to add more and more later on.
https://pymotw.com/3/json/
Recommended Tutorials:
Reply
#3
In addition, any programming language talks JSON.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
Thanks, a file it is then, though i thought it worth checking ..
Reply
#5
Thanks, a file it is then, though i thought it worth checking ..

Thanks, a file it is then, though i thought it worth checking ..
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Performance options for sys.stdout.writelines dgrunwal 11 3,110 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
  Can argparse support undocumented options? pjfarley3 3 2,191 Aug-14-2020, 06:13 AM
Last Post: pjfarley3
  Help with options raiden 1 1,920 Aug-30-2019, 12:57 AM
Last Post: scidam
  Creating a persistent list/database Trinx 1 2,250 Feb-27-2019, 06:20 PM
Last Post: ichabod801
  Display options - screen tcpip 2 2,833 Feb-06-2018, 02:41 PM
Last Post: tcpip
  Return options Kongurinn 1 3,290 Sep-28-2017, 03:02 PM
Last Post: ichabod801
  Python Launch Options Flexico 6 7,045 Dec-07-2016, 06:58 AM
Last Post: Flexico

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020