Update to v2.1

This commit is contained in:
Lost-MSth
2021-01-21 14:42:57 +08:00
parent 98358ad216
commit c6bb4c9afb
16 changed files with 1238 additions and 1446 deletions

View File

@@ -0,0 +1,25 @@
import sqlite3
class Connect():
# 数据库连接类,上下文管理
def __init__(self, file_path='./database/arcaea_database.db'):
"""
数据库连接默认连接arcaea_database.db
接受:文件路径
返回sqlite3连接操作对象
"""
self.file_path = file_path
def __enter__(self):
self.conn = sqlite3.connect(self.file_path)
self.c = self.conn.cursor()
return self.c
def __exit__(self, exc_type, exc_val, exc_tb):
if self.conn:
self.conn.commit()
self.conn.close()
return True