forked from mmcc-xx/WhosAtMyFeeder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
33 lines (28 loc) · 865 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import sqlite3
import yaml
def load_config():
file_path = os.getenv("CONFIG_PATH", "./config/config.yml")
with open(file_path, "r") as config_file:
config = yaml.safe_load(config_file)
return config
def setupdb():
config = load_config()
conn = sqlite3.connect(config["database"]["path"])
cursor = conn.cursor()
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS detections (
id INTEGER PRIMARY KEY AUTOINCREMENT,
detection_time TIMESTAMP NOT NULL,
detection_index INTEGER NOT NULL,
score REAL NOT NULL,
display_name TEXT NOT NULL,
category_name TEXT NOT NULL,
frigate_event TEXT NOT NULL UNIQUE,
camera_name TEXT NOT NULL
)
"""
)
conn.commit()
conn.close()