-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |