This repository has been archived on 2024-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
local-llm-server/llm_server/database/conn.py

29 lines
639 B
Python

import pymysql
class DatabaseConnection:
host: str = None
username: str = None
password: str = None
database: str = None
def init_db(self, host, username, password, database):
self.host = host
self.username = username
self.password = password
self.database = database
def cursor(self):
db = pymysql.connect(
host=self.host,
user=self.username,
password=self.password,
database=self.database,
charset='utf8mb4',
autocommit=True,
)
return db.cursor()
database = DatabaseConnection()