File size: 945 Bytes
17e971c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

ALLOWED_TYPE = "push_msg"  # 允许的信息详情类型


def init_db():
    import public
    from db import Sql

    db = Sql()
    db.dbfile("msg_box")
    create_sql_str = (
        "CREATE TABLE IF NOT EXISTS 'push_msg' ("
        "id INTEGER PRIMARY KEY AUTOINCREMENT, "
        "pid INTEGER NOT NULL UNIQUE DEFAULT 0, "
        "push_type TEXT NOT NULL DEFAULT '', "
        "push_title TEXT NOT NULL DEFAULT '', "
        "data TEXT NOT NULL DEFAULT '{}'"
        ");"
    )
    res = db.execute(create_sql_str)
    if isinstance(res, str) and res.startswith("error"):
        public.WriteLog("消息盒子", "建表push_msg失败")
        return

    index_sql_str = "CREATE INDEX IF NOT EXISTS 'push_pid_index' ON 'push_msg' ('pid');"

    res = db.execute(index_sql_str)
    if isinstance(res, str) and res.startswith("error"):
        public.WriteLog("消息盒子", "为push_msg建立索引push_pid_index失败")
        return