Files
eACGM/eacgm/webui/connect.py
2025-08-07 10:14:54 +08:00

19 lines
520 B
Python

# connect to mysql database
import mysql.connector
class database:
def __init__(self, ip, port, user, pwd, database) -> None:
self.conn = mysql.connector.connect(
host = ip,
port = port,
user = user,
password = pwd,
database = database
)
self.cursor = self.conn.cursor()
def exec(self, cmd: str):
self.cursor.execute(cmd)
result = self.cursor.fetchall()
self.conn.commit()
return result