feat: 基本架构

This commit is contained in:
Rock Chin
2022-12-07 22:27:05 +08:00
parent 4ed13bcdf2
commit 4303487d32
11 changed files with 126 additions and 5 deletions

0
pkg/database/__init__.py Normal file
View File

35
pkg/database/manager.py Normal file
View File

@@ -0,0 +1,35 @@
import pymysql
inst = None
class DatabaseManager:
host = ''
port = 0
user = ''
password = ''
database = ''
conn = None
cursor = None
def __init__(self, host: str, port: int, user: str, password: str, database: str):
self.host = host
self.port = port
self.user = user
self.password = password
self.database = database
self.reconnect()
global inst
inst = self
def reconnect(self):
self.conn = pymysql.connect(host=self.host, port=self.port, user=self.user, password=self.password,
database=self.database)
self.cursor = self.conn.cursor()
def get_inst() -> DatabaseManager:
global inst
return inst