Database Reader - Code

From RoboWiki
Revision as of 17:48, 9 June 2024 by Robot (talk | contribs) (Created page with "Return back to project page: Door camera - Jakub Vojtek Python code for the Database Reader: <syntaxhighlight lang=python> impo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Return back to project page: Door camera - Jakub Vojtek

Python code for the Database Reader:

 
import sqlite3

# Connect to the SQLite database
conn = sqlite3.connect('database/face_images.db')
c = conn.cursor()

def print_data():
    c.execute('SELECT * FROM images')
    rows = c.fetchall()
    for row in rows:
        print(row)


def delete_data_with_no_faces():
    c.execute('DELETE FROM images WHERE detected_faces = 0')


conn.close()