BrickTracker/database.py

90 lines
1.7 KiB
Python
Raw Normal View History

2024-04-16 21:35:15 +02:00
import sqlite3
from pathlib import Path # creating folders
2024-04-17 22:43:02 +02:00
import sys
2024-04-16 21:35:15 +02:00
conn = sqlite3.connect('app.db')
cursor = conn.cursor()
2024-04-17 22:43:02 +02:00
if len(sys.argv) > 1:
cursor.execute('DELETE FROM sets where u_id="' +sys.argv[1]+ '";')
conn.commit()
cursor.execute('DELETE FROM inventory where u_id="' +sys.argv[1]+ '";')
conn.commit()
cursor.execute('DELETE FROM minifigures where u_id="' +sys.argv[1]+ '";')
conn.commit()
cursor.execute('DELETE FROM missing where u_id="' +sys.argv[1]+ '";')
conn.commit()
cursor.close()
conn.close()
exit()
2024-04-16 21:35:15 +02:00
2024-04-18 20:08:04 +02:00
cursor.execute('''DROP TABLE sets''')
cursor.execute('''DROP TABLE inventory''')
cursor.execute('''DROP TABLE minifigures''')
cursor.execute('''DROP TABLE missing''')
2024-04-16 21:35:15 +02:00
cursor.execute('''CREATE TABLE IF NOT EXISTS sets (
set_num TEXT,
name TEXT,
year INTEGER,
theme_id INTEGER,
num_parts INTEGER,
set_img_url TEXT,
set_url TEXT,
last_modified_dt TEXT,
2024-04-18 20:08:04 +02:00
mini_col BOOLEAN,
set_check BOOLEAN,
2024-04-18 22:11:44 +02:00
set_col BOOLEAN,
2024-04-16 21:35:15 +02:00
u_id TEXT
)''')
cursor.execute('''CREATE TABLE IF NOT EXISTS inventory (
set_num TEXT,
id INTEGER,
part_num INTEGER,
name TEXT,
part_img_url TEXT,
part_img_url_id TEXT,
color_id INTEGER,
color_name TEXT,
quantity INTEGER,
is_spare BOOLEAN,
element_id INTEGER,
u_id TEXT
)''')
cursor.execute('''CREATE TABLE IF NOT EXISTS minifigures (
2024-04-17 22:43:02 +02:00
fig_num TEXT,
2024-04-16 21:35:15 +02:00
set_num TEXT,
name TEXT,
quantity INTEGER,
set_img_url TEXT,
u_id TEXT
)''')
cursor.execute('''CREATE TABLE IF NOT EXISTS missing (
set_num TEXT,
id INTEGER,
part_num INTEGER,
2024-04-26 16:42:40 +02:00
part_img_url_id TEXT,
2024-04-16 21:35:15 +02:00
color_id INTEGER,
quantity INTEGER,
element_id INTEGER,
u_id TEXT
)''')
conn.close()