diff --git a/db/ddl.sql b/db/ddl.sql new file mode 100644 index 0000000..d38a249 --- /dev/null +++ b/db/ddl.sql @@ -0,0 +1,45 @@ +create table main.menu +( + name text + constraint menu_pk + primary key, + label text, + order_num integer, + expression text +); + +create table main.roll_result +( + datestr text + constraint roll_result_pk + primary key, + value text +); + +create table main.sqlite_master +( + type TEXT, + name TEXT, + tbl_name TEXT, + rootpage INT, + sql TEXT +); + +create table main.user_menu +( + user text, + menu text, + datestr text, + nickname text, + primary key (user, datestr), + constraint user_menu_pk + unique (nickname, datestr) +); + +create table main.users +( + nickname text + constraint users_pk + primary key +); + diff --git a/src/dao.py b/src/dao.py index 8d3784b..466f95e 100644 --- a/src/dao.py +++ b/src/dao.py @@ -6,39 +6,6 @@ from utils import get_user db_path = './data.sqlite3' -ddl_db = sqlite3.connect(db_path) -ddl_cursor = ddl_db.cursor() -try: - ddl_cursor.execute(''' -create table if not exists user_menu -( - user text, - menu text, - datestr text, - primary key (user, datestr) -) -''') - ddl_cursor.execute(''' -create table if not exists roll_result -( - datestr text primary key, - value text -) - ''') - ddl_cursor.execute(''' -create table if not exists menu -( - name text primary key, - label text, - order_num integer, - expression text -) - ''') - ddl_db.commit() -finally: - ddl_cursor.close() - ddl_db.close() - def get_user_menu() -> tuple[str, str]: """