DDL单独抽取出来
This commit is contained in:
parent
818008fc74
commit
1b61b35c03
|
@ -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
|
||||
);
|
||||
|
33
src/dao.py
33
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]:
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue