This repository was archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__config.py
More file actions
executable file
·72 lines (57 loc) · 1.35 KB
/
__config.py
File metadata and controls
executable file
·72 lines (57 loc) · 1.35 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
import sqlite3
from typing import Union
DIR=os.getenv('DSD_DATABASE')
if DIR is None:
DIR='./.data'
DIR=os.path.abspath(DIR)
DEVICE='device'
DEVICE=os.path.join(DIR,DEVICE)
MODEL='%s.mdl'
MODEL=os.path.join(DEVICE,'%s',MODEL)
CALIBRATION='calibration'
CALIBRATION=os.path.join(DEVICE,'%s',CALIBRATION)
DB='main.db'
DB=os.path.join(DIR,DB)
os.makedirs(DEVICE,exist_ok=True)
con=sqlite3.connect(DB,check_same_thread=False)
# con.set_trace_callback(print)
def e(s:str,t:tuple=tuple())->Union[str,None]:
if t:
s=con.execute(s,t).fetchone()
else:
s=con.execute(s).fetchone()
con.commit()
if s is None:
return None
else:
return s[0]
e('''
create table if not exists admin(
username varchar(64) primary key not null,
email varchar(256),
password varchar(64) not null
);
''')
e('''
create table if not exists device(
uuid varchar(64) primary key not null,
email varchar(256),
calibration varchar(256)
);
''')
e('''
create table if not exists model(
uuid varchar(64) not null,
algo varchar(64),
path varchar(256),
primary key(uuid,algo),
foreign key(uuid) references device(uuid)
);
''')
if __name__=='__main__':
print(DIR)
print(DEVICE)
print(MODEL)
print(CALIBRATION)
print(DB)