yipao.databases.mysql.MySql

class yipao.databases.mysql.MySql(host: str, user: str, password: str, database: str, port: int = 3306)[source]

Class to handle interactions with a MySQL database. Manages connections and performs database operations securely and efficiently.

__init__(host: str, user: str, password: str, database: str, port: int = 3306)[source]

Initializes the MySQLDatabase instance with connection parameters.

Args: host (str): Hostname of the MySQL server. user (str): Username to connect to the database. password (str): Password for the database user. database (str): Name of the database to connect to. port (int, optional): Port number on which the MySQL server is listening. Defaults to 3306.

Methods

__init__(host, user, password, database[, port])

Initializes the MySQLDatabase instance with connection parameters.

close()

Closes the connection to the MySQL database.

connect()

Creates a connection to the MySQL database using the instance's configuration.

describe_database(database)

Describes the Data Definition Language (DDL) structure and relationships of all tables.

describe_ddl(table)

Describes the Data Definition Language (DDL) structure and relationships of a given table.

execute_query(query[, markdown])

Executes a query on the MySQL database.