-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_database.py
37 lines (32 loc) · 934 Bytes
/
setup_database.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sqlite3
def setup_database():
conn = sqlite3.connect('photos.db')
cursor = conn.cursor()
# Create photo table
cursor.execute('''
CREATE TABLE IF NOT EXISTS photo (
id INTEGER PRIMARY KEY AUTOINCREMENT,
file_path TEXT NOT NULL,
caption TEXT,
date_taken TEXT,
latitude REAL,
longitude REAL,
location_name TEXT,
exif_data TEXT,
photographer TEXT
)
''')
# Create point_of_interest table
cursor.execute('''
CREATE TABLE IF NOT EXISTS point_of_interest (
id INTEGER PRIMARY KEY AUTOINCREMENT,
photo_id INTEGER,
name TEXT NOT NULL,
description TEXT,
FOREIGN KEY (photo_id) REFERENCES photo (id)
)
''')
conn.commit()
conn.close()
if __name__ == '__main__':
setup_database()