- HOW TO INSTALL SQLITE DATABASE ON A RASPBERRYPI HOW TO
- HOW TO INSTALL SQLITE DATABASE ON A RASPBERRYPI SOFTWARE
- HOW TO INSTALL SQLITE DATABASE ON A RASPBERRYPI CODE
SQLite is lightweight as a database, and the Raspberry Pi board is also a lightweight minicomputer. The Lite is SQLite relates to its lightweight nature.
It is serverless, transactional, self-contained, and requires zero configurations to implement it successfully. It is distinctively unique from other database management systems because of its noticeable features.
HOW TO INSTALL SQLITE DATABASE ON A RASPBERRYPI SOFTWARE
It is a software library defined under the C programming language. Since rain is so rare here, me and the dog are going for a walk.SQLite is system software that serves as a relational database management system. But right this second it started to sprinkle outside.
HOW TO INSTALL SQLITE DATABASE ON A RASPBERRYPI CODE
Now, I need to decide if I should work on a web page to display the status of the thermostats or start combining the various pieces of code I've constructed together to monitor the house. Knowing a device is doing well is a constant concern when you have a bunch of them that are working independently around the house. Later, I can look at that time to see if the devices are having a problem. Since that was easy, I decided to put the actual time I last talked to a particular device in the data base as well. This will make the eventual loading of data by a web server much easier. I managed to prove that I can pass data from independent processes through the data base. Rather than being an inconvenience, this is actually great. I noticed this when Sqlite3 refused a connection because I opened the data base in one thread and then tried to use it in another one. This led to an interesting discovery, the scheduler starts a new thread to do the work. Once again, I set up the scheduler to cause things to happen. Now that I know how, I'll have to think about doing the same thing when I adapt this to talk to my little XBee devices. While I was working on it, I decided to get a little bit fancy and actually put the location and IP addresses of the two thermostats in the data base, retrieving and using them in the communication process. This works really well to interrogate each thermostat and put the results into a data base. # I want to look into using atexit for this # all the real work is done by the scheduler # This is a priming read to show immediate results Sched.add_interval_job(ThermostatStatus, minutes=1) # schedule reading the thermostats for every minute # being called, because they take care of themselves # that way I don't have to worry about them Print whichOne + " reports: " + str(status)Ĭ.execute("update thermostats set 'temp-reading' = ?, " # open the database and set up the cursor (I don't have aĭbconn = nnect('/home/pi/database/desert-home')Ĭ.execute("select address from thermostats " # so I have to open and close the database within # The scheduler will run this as a separate thread # and separate the values into a list that can # the arduino thermostat, strip off the trailing cr,lf # After getting the status from the little web server on # now read the status that came back from it Website = openSite("HTTP://" + whichOne + "/status") Print "Cannot retrieve URL: Unknown error" Print "Cannot retrieve URL: " + str(e.code) + ": " + errorDesc As usual, here's the code I came up with:įrom apscheduler.scheduler import SchedulerĮrrorDesc = There's not a huge set up, actually, there wasn't much set up at all.
HOW TO INSTALL SQLITE DATABASE ON A RASPBERRYPI HOW TO
Once again, there was a ton of information on the web about how to use Sqlite3, and things went pretty smoothly. The idea is that I can put up a web page that shows the status of the two thermostats and eventually add controls to change the settings. I chose to monitor my thermostats, since they are ethernet enabled and respond directly to requests, then to store their current state in the data base. So, after installing Sqlite3 on my Pi, I spent about two hours cobbling together enough code to try it out. Since the interface language is SQL, whatever I wind up doing can be ported to a larger data base tool when I need to.
It seems like a reasonable choice for a really small system since it doesn't require a manager process and isn't split across multiple controllers. After reading way too much information on various data base managers, I decided to test Sqlite3. I've been setting up a new Raspberry Pi to control my house and decided to experiment with a data base to store current data in so multiple processes can get at it. If you got here through a search engine looking for a tutorial on Sqlite3 on the Raspberry Pi, that's not what this is.