Archived
更新数据库下载地址
This commit is contained in:
2 files changed
+12
-6
No files matched your search
+11
-5
@@ -7,19 +7,25 @@
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import requests
|
||||
|
||||
|
||||
def download():
|
||||
res = requests.get('https://syncdatabase.herokuapp.com/sync/')
|
||||
with open('./app/db/data.db', 'wb') as fp:
|
||||
res = requests.get('https://markusjoe.github.io/static_file_hosting/data.sqlite')
|
||||
with open('./app/db/data.sqlite', 'wb') as fp:
|
||||
fp.write(res.content)
|
||||
|
||||
|
||||
if __name__ != '__main__':
|
||||
if not os.path.exists('./app/db/data.db'):
|
||||
if not os.path.exists('./app/db/data.sqlite'):
|
||||
print('数据库文件未找到, 正在下载中')
|
||||
download()
|
||||
print('下载完成')
|
||||
try:
|
||||
download()
|
||||
print('下载完成')
|
||||
except Exception as error:
|
||||
print('下载失败, 错误原因:', error)
|
||||
print('请手动下载数据库文件到 ./app/db/data.sqlite')
|
||||
sys.exit(1)
|
||||
|
||||
__all__ = ['db']
|
||||
+1
-1
@@ -18,7 +18,7 @@ class SQLite:
|
||||
初始化SQLite对象
|
||||
完成后会自动提交, 自动关闭
|
||||
"""
|
||||
self.__path = './app/db/data.db'
|
||||
self.__path = './app/db/data.sqlite'
|
||||
self.__conn = sqlite3.connect(self.__path)
|
||||
self.__cursor = self.__conn.cursor()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user