Skip to content

Commit

Permalink
utils.py for refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pdr21001 authored Apr 23, 2025
1 parent bff7b58 commit 604d71e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions backend/utils.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 604d71e

Please sign in to comment.