Introduction When working with FastAPI and SQLAlchemy, you may encounter an issue where your tables are not created in the database even though your code seems to be correctly set up. A common reason for this is having multiple instances of declarative_base instead of a single shared instance. In this blog post, we'll walk you … Continue reading Organising SQLAlchemy Base and Models in FastAPI Projects
Tag: python
Logging a Python App to journald
So I thought logging in Python would be easy. You start logging to the command line then when that gets too much you log to a file. A bit of me still feels logging to a file in the app directory is the easiest set up. But various articles on the Internet say file logging … Continue reading Logging a Python App to journald
Getting Frames from YouTube
YouTube has a wealth of data but often you don't feel like downloading it all to disk. How can we stream video to python and then access the frame data?
Playing Around with Retinal-Cortex Mappings
Here is a little notebook where I play around with converting images from a polar representation to a Cartesian representation. This is similar to the way our bodies map information from the retina onto the early visual areas. Mapping from the visual field (A) to the thalamus (B) to the cortex (C) These ideas are … Continue reading Playing Around with Retinal-Cortex Mappings
First Steps into the Quantified Self: Getting to Know the Fitbit API
Today I have been experimenting with the Fitbit API. Here are some rather amateurish steps for getting data from Fitbit's "cloud". Simple Client Setup for Public Data 1. Get and setup a Fitbit product. I have access to a set of Fitbit scales (the "Aria"). The Fitbit Force looks quite good; I may get one … Continue reading First Steps into the Quantified Self: Getting to Know the Fitbit API
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
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
Simple Energy Monitoring on Raspberry Pi
So. Reading an LCD screen was more difficult than I first assumed. My code is still good for reading my Thermostat values. However for energy monitoring and £20 I found a better solution. Looking on the net a particular model of energy monitor was recommended for easy monitoring: the Current Cost EnviR. This monitor has … Continue reading Simple Energy Monitoring on Raspberry Pi