speed-camera
speed-camera copied to clipboard
Added optional postgres functionality to db
I added support for a remote postgres database. I plan to operate multiple cameras on two devices that feed into a single database and will make a webserver that can then just query that single database to generate neat plots.
In order to do that I had to add a few dependencies, primarily psycopg2. I also added python-dotenv to securely store super secret stuff. I developed and tested in the dev container, so it should be good to go but I won't be offended if I made a bonehead mistake.
Thanks for your work on this project. I have reviewed your changes and have a few requests.
- If possible db_conn line 40 print statements should be changed to appropriate logging message.
- DB_TYPE in db_conn needs to be converted to lowercase since user might input mixed case.
- I prefer you move dotenv code out of config.py and move to db_conn.py. Move config.py DB_USER and DB_PASSWORD vars out. Add config.py comment regarding using .env file. I suggest moving logic to db_conn after elif DB_TYPE == 'postgres'. Check for .env file using find_dotenv(). If not found create .env file with required entries with None values. Then error out with message for user to edit the .env file to add progress db user and password to the .env file entries. For additional detail see https://stackoverflow.com/questions/64734118/environment-variable-not-loading-with-load-dotenv-in-linux.
Let me know what you think.
byw I setup a progressql db on one of my RPI's per https://pimylifeup.com/raspberry-pi-postgresql/
Have not tested. Will wait for your reply Thanks Claude ...