Module Contents

runner.mysql.wait_for_mysql(max_seconds: int = 20)[source]

With a freshly created container mysql might need a bit of time to prime its files. This functions waits up to max_seconds seconds.

runner.mysql.get_mysql_client(user: str = 'root', password: str = 'secret', database: Optional[str] = '', **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()
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.show_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.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: Project, dry_run: bool = False)[source]

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