Database Reader - Code
From RoboWiki
Return back to project page: Door camera - Jakub Vojtek
Python code for the Database Reader:
import sqlite3
def print_data():
with sqlite3.connect('database/face_images.db') as conn:
c = conn.cursor()
c.execute('SELECT * FROM images')
rows = c.fetchall()
for row in rows:
print(row)
def delete_data_with_no_faces():
with sqlite3.connect('database/face_images.db') as conn:
c = conn.cursor()
c.execute('DELETE FROM images WHERE detected_faces = 0')
conn.commit()
if __name__ == '__main__':
print("Data before deletion:")
print_data()
delete_data_with_no_faces()
print("Data after deletion:")
print_data()