Skip to content

How to Manage Sqlite3 Database

Claude Pageau edited this page Jul 1, 2021 · 14 revisions

There are several ways to archive, reset or start a fresh speed camera sqlite3 database. The sqlite3 database and schema structure will automatically be created by speed-cam.py.

First stop speed_cam.py using menubox.sh or from console using speed-cam.sh stop

Below is a list of options.

1. Rename data/speed_cam.db to another name

cd ~/speed-camera
mv data/speed_cam.db data/speed_cam_30jun21.db

A fresh copy will be created on restart. If you do not delete images you can restore back to old database by changing the DB_NAME in config.py.

2. Delete data/speed_cam.db

rm data/dpeed_cam.db

Also see How to View Speed Camera Data

The database and structure will be recreated on next restart but your db history will be lost.

3. Change config.py sqlite3 variable settings

You can change any of the following or any combination in config.py. I suggest just creating a new db table. eg DB_TABLE= "speed2". The speed table will still exist and you can change back to it if you want to run historical reports or graphs.

# Sqlite3 Settings   in config.py
# ----------------
DB_DIR   = "data"
DB_NAME  = "speed_cam.db"
DB_TABLE = "speed"

You can then decide if you want to keep media/images or start a new media/images folder or delete everything.. Depending on what you do above and how much space you have..

Simplest would be just to change db name eg DB_NAME = "speed_cam_2.db"

Restart speed_cam.py

If you are having problems with media/recent then the symbolic links can just be deleted and new ones will be created as new data and images are collected.

cd~/speed-camera
rm media/recent/*

(Optional) You can also create custom plugins for special database configuration changes or settings.

Also see How to View Speed Camera Data