MongoDB with Docker – Quick Refresh

Quick refresh on one way to manage a Mongo database for access by Python programs. Set a directory to store the database. Let's call this /mnt/mongodata. Then run a docker container with the most recent version of MongoDB: docker run --name mongoserver -p 27017:27017 -v /mnt/mongodata:/data/db  mongo. Just for completeness: the "--name" flag allows us … Continue reading MongoDB with Docker – Quick Refresh

Using Alembic to Migrate SQLAlchemy Databases

There are several advantages of using SQLAlchemy as a wrapper for an SQL database. These include stability with large numbers of data records, class/object-oriented approach, plug-and-play underlying databases. However, one under-documented disadvantage is poor change management. If you add a field or table you generally need to regenerate the entire database. This is a pain if … Continue reading Using Alembic to Migrate SQLAlchemy Databases

Doing Useful Things with WeMo Motion

Using both the WeMo Motion rules and IFTTT allows you to do certain things with this motion detector. However, to expand our possibilities it would help if we could store our motion data and make it accessible to the programs that we write. To store our motion data in a database we need a bit … Continue reading Doing Useful Things with WeMo Motion

Accessing Our Sensor Data: PHP + SQLite + SVG

So we have our sensor(s) dutifully logging their data to an SQLite database. Now we need to process and view this data. LASP First we need to set our Raspberry Pi up as a webserver. This typically requires: Linux, Apache, MySQL and PHP - a LAMP framework. There is a handy guide: here (thanks Dave!). … Continue reading Accessing Our Sensor Data: PHP + SQLite + SVG

Databases for Sensor Data in Python

Here are some options to persistently store sensor data in a database using python. Anydbm For simple key-value pairs the anydbm module looks the best. It stores values as strings. Because of this you may need to use another module called pickle to convert non-string values into strings. For example: import anydbm, pickle from datetime … Continue reading Databases for Sensor Data in Python