更新数据库下载地址

This commit is contained in:
MarkusJoe
2022-04-04 13:55:46 +08:00
parent 10c425d5c8
commit b2b509e53b
2 files changed
+12 -6

No files matched your search

+9 -3
View File
@@ -7,19 +7,25 @@
import os import os
import sys
import requests import requests
def download(): def download():
res = requests.get('https://syncdatabase.herokuapp.com/sync/') res = requests.get('https://markusjoe.github.io/static_file_hosting/data.sqlite')
with open('./app/db/data.db', 'wb') as fp: with open('./app/db/data.sqlite', 'wb') as fp:
fp.write(res.content) fp.write(res.content)
if __name__ != '__main__': if __name__ != '__main__':
if not os.path.exists('./app/db/data.db'): if not os.path.exists('./app/db/data.sqlite'):
print('数据库文件未找到, 正在下载中') print('数据库文件未找到, 正在下载中')
try:
download() download()
print('下载完成') print('下载完成')
except Exception as error:
print('下载失败, 错误原因:', error)
print('请手动下载数据库文件到 ./app/db/data.sqlite')
sys.exit(1)
__all__ = ['db'] __all__ = ['db']
+1 -1
View File
@@ -18,7 +18,7 @@ class SQLite:
初始化SQLite对象 初始化SQLite对象
完成后会自动提交, 自动关闭 完成后会自动提交, 自动关闭
""" """
self.__path = './app/db/data.db' self.__path = './app/db/data.sqlite'
self.__conn = sqlite3.connect(self.__path) self.__conn = sqlite3.connect(self.__path)
self.__cursor = self.__conn.cursor() self.__cursor = self.__conn.cursor()