🎈 perf(项目结构): 优化项目结构,数据文件单独放置,依赖文件

优化项目结构,数据文件单独放在一个文件夹里边,使用`pathlib`模块,添加项目所依赖的库。
This commit is contained in:
WhaleFall
2021-08-10 17:20:41 +08:00
parent c1a4b221db
commit 8239da606d
6 changed files with 11 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
'''
Author: whalefall
Date: 2021-08-07 21:23:35
LastEditTime: 2021-08-09 19:12:32
LastEditTime: 2021-08-10 17:10:07
Description: 异步轰炸
'''
import asyncio

View File

0
db/data.json Normal file
View File

3
requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
requests==2.24.0
aiohttp==3.7.3
pathlib

View File

@@ -3,18 +3,21 @@
'''
Author: whalefall
Date: 2021-08-07 14:59:08
LastEditTime: 2021-08-07 21:31:13
LastEditTime: 2021-08-10 17:08:54
Description: python操作数据库
'''
import sqlite3
import sys
from pathlib import Path
class Sql(object):
def __init__(self) -> None:
'''初始化数据库'''
# 数据库路径
db_path = Path.cwd().joinpath("db", "data.db")
# 连接数据库,不检查是否在同一个路径.
self.client = sqlite3.connect(
"data.db", timeout=6, check_same_thread=False)
db_path, timeout=6, check_same_thread=False)
self.cursor = self.client.cursor()
self.newTable()
@@ -67,3 +70,4 @@ if __name__ == "__main__":
s = Sql()
s.update("SWDWQ")
print(s.select())
# print(Path.cwd().joinpath("db","data.db"))