Example #1
0
isExists = os.path.exists(Data_Path)
if not isExists:
    os.mkdir(Data_Path)

SQL_Path = Data_Path + 'encrypt_store'

AESCoder('CmKEzRQKD3UxmRGD')

if os.path.exists(SQL_Path) and os.path.isfile(SQL_Path):
    # print('初始化内存数据库')
    try:
        f = open(SQL_Path, 'rb')
        text = AESCoder.decrypt(f.read())
        f.close()
        # print('解密内容', text)
        db = __db__.connection()
        db.cursor().executescript(text)
        db.commit()
        db.row_factory = sqlite3.Row
    except Exception as e:
        # print('初始化内存数据库错误, 创建数据库表', e)
        __db__.create_tables([Config])
else:
    # print('创建数据库表')
    __db__.create_tables([Config])

# 延时保存
timer: threading.Timer = None


# 保存数据库为二进制文件