This repository has been archived on 2026-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2022-03-26 08:02:25 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -- coding:utf-8 --
|
|
|
|
|
# @Author: markushammered@gmail.com
|
|
|
|
|
# @Development Tool: PyCharm
|
|
|
|
|
# @Create Time: 2022/3/25
|
|
|
|
|
# @File Name: __init__.py.py
|
2022-04-02 18:03:25 +08:00
|
|
|
|
|
|
|
|
|
2022-04-04 13:51:24 +08:00
|
|
|
import os
|
2022-04-04 13:55:46 +08:00
|
|
|
import sys
|
2022-04-04 13:51:24 +08:00
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def download():
|
2022-04-04 13:55:46 +08:00
|
|
|
res = requests.get('https://markusjoe.github.io/static_file_hosting/data.sqlite')
|
|
|
|
|
with open('./app/db/data.sqlite', 'wb') as fp:
|
2022-04-04 13:51:24 +08:00
|
|
|
fp.write(res.content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ != '__main__':
|
2022-04-04 13:55:46 +08:00
|
|
|
if not os.path.exists('./app/db/data.sqlite'):
|
2022-04-04 13:51:24 +08:00
|
|
|
print('数据库文件未找到, 正在下载中')
|
2022-04-04 13:55:46 +08:00
|
|
|
try:
|
|
|
|
|
download()
|
|
|
|
|
print('下载完成')
|
|
|
|
|
except Exception as error:
|
|
|
|
|
print('下载失败, 错误原因:', error)
|
|
|
|
|
print('请手动下载数据库文件到 ./app/db/data.sqlite')
|
|
|
|
|
sys.exit(1)
|
2022-04-04 13:51:24 +08:00
|
|
|
|
2022-04-02 18:03:25 +08:00
|
|
|
__all__ = ['db']
|