runner.mysql

Module Contents

Functions

ensure_mysql(func)

Decorator to raise an exception before running a function in case the MySQL

get_system_mysql_client() → pymysql.cursors.Cursor

get_project_mysql_client(project: derex.runner.project.Project) → pymysql.cursors.Cursor

get_mysql_client(host: str, user: str, password: str, port: int = 3306, database: Optional[str] = None, **kwargs) → pymysql.cursors.Cursor

Return a cursor on the mysql server. If the connection object is needed

show_databases() → List[Tuple[str, int, int]]

List all existing databases together with some

list_users() → Optional[Tuple[Tuple[str, str, str]]]

List all mysql users.

create_database(database_name: str)

Create a database if doesn’t exists.

create_user(user: str, password: str, host: str)

Create a user if doesn’t exists.

drop_database(database_name: str)

Drops the selected database.

drop_user(user: str, host: str)

Drops the selected user.

execute_root_shell(command: Optional[str])

Open a root shell on the mysql database. If a command is given

copy_database(source_db_name: str, destination_db_name: str)

Copy an existing MySQL database. This actually involves exporting and importing back

reset_mysql_openedx(project: derex.runner.project.Project, dry_run: bool = False)

Run script from derex/openedx image to reset the mysql db.

reset_mysql_password(current_password: str)

Reset the mysql root user password.

Attributes

logger

MYSQL_ROOT_PASSWORD

runner.mysql.logger[source]
runner.mysql.MYSQL_ROOT_PASSWORD[source]
runner.mysql.ensure_mysql(func)[source]

Decorator to raise an exception before running a function in case the MySQL server is not available.

runner.mysql.get_system_mysql_client()pymysql.cursors.Cursor[source]
runner.mysql.get_project_mysql_client(project: derex.runner.project.Project)pymysql.cursors.Cursor[source]
runner.mysql.get_mysql_client(host: str, user: str, password: str, port: int = 3306, database: Optional[str] = None, **kwargs)pymysql.cursors.Cursor[source]

Return a cursor on the mysql server. If the connection object is needed it can be accessed from the cursor object:

mysql_client = get_mysql_client()
mysql_client.connection.autocommit(True)
runner.mysql.show_databases()List[Tuple[str, int, int]][source]

List all existing databases together with some useful infos (number of tables, number of Django users).

runner.mysql.list_users()Optional[Tuple[Tuple[str, str, str]]][source]

List all mysql users.

runner.mysql.create_database(database_name: str)[source]

Create a database if doesn’t exists.

runner.mysql.create_user(user: str, password: str, host: str)[source]

Create a user if doesn’t exists.

runner.mysql.drop_database(database_name: str)[source]

Drops the selected database.

runner.mysql.drop_user(user: str, host: str)[source]

Drops the selected user.

runner.mysql.execute_root_shell(command: Optional[str])[source]

Open a root shell on the mysql database. If a command is given it is executed.

runner.mysql.copy_database(source_db_name: str, destination_db_name: str)[source]

Copy an existing MySQL database. This actually involves exporting and importing back the database with a different name.

runner.mysql.reset_mysql_openedx(project: derex.runner.project.Project, dry_run: bool = False)[source]

Run script from derex/openedx image to reset the mysql db.

runner.mysql.reset_mysql_password(current_password: str)[source]

Reset the mysql root user password.