diff --git a/backend/utils.py b/backend/utils.py new file mode 100644 index 0000000..cfe1eaf --- /dev/null +++ b/backend/utils.py @@ -0,0 +1,31 @@ +# utils.py +import sqlite3 + +def create_tables(conn): + """Create tables for the database if they do not exist.""" + cursor = conn.cursor() + + cursor.execute(''' + CREATE TABLE IF NOT EXISTS animals ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + species TEXT NOT NULL, + breed TEXT, + age INTEGER, + personality TEXT, + image_path TEXT, + adoption_status TEXT DEFAULT 'Available' + ) + ''') + + cursor.execute(''' + CREATE TABLE IF NOT EXISTS adopters ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + username TEXT UNIQUE NOT NULL, + password TEXT NOT NULL, + email TEXT UNIQUE, + join_date TEXT DEFAULT CURRENT_TIMESTAMP + ) + ''') + + conn.commit()