This repository was archived by the owner on Jun 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.py
More file actions
49 lines (42 loc) · 1.42 KB
/
init.py
File metadata and controls
49 lines (42 loc) · 1.42 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
"""
Copyright (c) [2019] [sixlab.cn]
[https://github.com/PatrickRoot/six-site] is licensed under the Mulan PSL v1.
You can use this software according to the terms and conditions of the Mulan PSL v1.
You may obtain a copy of Mulan PSL v1 at:
http://license.coscl.org.cn/MulanPSL
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
PURPOSE.
See the Mulan PSL v1 for more details.
"""
import json
from config.db import select_one, run_sql, select_list
def add_update_config(key, val, replace):
site_config = select_one('''
select *
from site_config
where config_key = ?
''', (key,))
if not site_config:
run_sql('''
INSERT INTO site_config
(config_key, config_val)
VALUES
(?, ?);
''', (key, val))
elif replace:
run_sql('''
UPDATE site_config
SET config_val = ?
WHERE config_key = ?
''', (val, key))
if __name__ == '__main__':
add_update_config("domain", "", False)
add_update_config("telegram.url", "", False)
add_update_config("telegram.token", "", False)
add_update_config("mine.help", "", False)
site_config = select_list('''
select *
from site_config
''', ())
print(json.dumps(site_config))