Archived
为代码添加了注释
This commit is contained in:
7 files changed
+32
-15
No files matched your search
@@ -4,3 +4,17 @@
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/4
|
||||
# @File Name: __init__.py.py
|
||||
|
||||
|
||||
import os
|
||||
|
||||
if not os.path.exists('./db/count.db'):
|
||||
print('未检测到数据库')
|
||||
import sqlite3
|
||||
conn = sqlite3.connect('./db/count.db', check_same_thread=False)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('create table ReqCount (name text primary key, times int)')
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
print('已在./db 目录下创建了count.db数据库')
|
||||
BIN
Binary file not shown.
@@ -34,7 +34,7 @@ def fetch_data(name: str) -> int:
|
||||
:param name:
|
||||
:return:
|
||||
"""
|
||||
conn = sqlite3.connect('./db/d.db', check_same_thread=False)
|
||||
conn = sqlite3.connect('./db/count.db', check_same_thread=False)
|
||||
cursor = conn.cursor()
|
||||
try:
|
||||
cursor.execute('select * from ReqCount')
|
||||
@@ -42,7 +42,7 @@ def fetch_data(name: str) -> int:
|
||||
data = cursor.fetchall()
|
||||
|
||||
temp_dict = {}
|
||||
for k, v in data:
|
||||
for k, v in data: # 遍历数据将元组数据转换为字典类型
|
||||
temp_dict.setdefault(k, []).append(v)
|
||||
for i, c in zip(temp_dict.keys(), temp_dict.values()):
|
||||
temp_dict[i] = c[0]
|
||||
|
||||
Reference in New Issue
Block a user