pageauc / speed-camera

A Unix, Windows, Raspberry Pi Object Speed Camera using python, opencv, video streaming, motion tracking. Includes a Standalone Web Server Interface, Image Search using opencv template match and a whiptail Admin Menu Interface Includes picam and webcam Plugins for motion track security camera configuration including rclone sync script. watch-app allows remotely controller camera configuration from a remote storage service name. Uses sqlite3 and gnuplot for reporting. Recently added openalpr license plate reader support.
Apache License 2.0
987 stars 173 forks source link

Added optional postgres functionality to db #157

Open nick-fournier opened 11 months ago

nick-fournier commented 11 months ago

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.

pageauc commented 8 months ago

Thanks for your work on this project. I have reviewed your changes and have a few requests.

  1. If possible db_conn line 40 print statements should be changed to appropriate logging message.
  2. DB_TYPE in db_conn needs to be converted to lowercase since user might input mixed case.
  3. 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 ...