From f615f9a8ffd4c98bb970cf6392c86b64442da804 Mon Sep 17 00:00:00 2001 From: Corentin Flr <10946971+cogk@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:00:56 +0200 Subject: [PATCH] fix: Use mariadb commands instead of mysql --- agent/bench.py | 4 ++-- agent/database.py | 2 +- agent/proxysql.py | 2 +- agent/site.py | 24 ++++++++++++------------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/agent/bench.py b/agent/bench.py index 8f91870d..0c99517a 100644 --- a/agent/bench.py +++ b/agent/bench.py @@ -257,7 +257,7 @@ def create_mariadb_user(self, site, mariadb_root_password, database=None): ] for query in queries: command = ( - f"mysql -h {self.host} -uroot -p{mariadb_root_password}" + f"mariadb -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"' ) self.execute(command) @@ -273,7 +273,7 @@ def drop_mariadb_user(self, site, mariadb_root_password, database=None): ] for query in queries: command = ( - f"mysql -h {self.host} -uroot -p{mariadb_root_password}" + f"mariadb -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"' ) self.execute(command) diff --git a/agent/database.py b/agent/database.py index 839b913c..1b9ee5db 100644 --- a/agent/database.py +++ b/agent/database.py @@ -27,7 +27,7 @@ def search_binary_log( log = os.path.join(self.mariadb_directory, log) LINES_TO_SKIP = r"^(USE|COMMIT|START TRANSACTION|DELIMITER|ROLLBACK|#)" command = ( - f"mysqlbinlog --short-form --database {database} " + f"mariadb-binlog --short-form --database {database} " f"--start-datetime '{start_datetime}' " f"--stop-datetime '{stop_datetime}' " f" {log} | grep -Piv '{LINES_TO_SKIP}'" diff --git a/agent/proxysql.py b/agent/proxysql.py index 50dabff2..6b06721d 100644 --- a/agent/proxysql.py +++ b/agent/proxysql.py @@ -18,7 +18,7 @@ def __init__(self, directory=None): def proxysql_execute(self, command): command = ( - "mysql -h 127.0.0.1 -P 6032 " + "mariadb -h 127.0.0.1 -P 6032 " f"-u frappe -p{self.proxysql_admin_password} " f"--disable-column-names -e '{command}'" ) diff --git a/agent/site.py b/agent/site.py index 047ca90f..df69878d 100644 --- a/agent/site.py +++ b/agent/site.py @@ -271,7 +271,7 @@ def create_database_access_credentials(self, mode, mariadb_root_password): ] for query in queries: command = ( - f"mysql -h {self.host} -uroot -p{mariadb_root_password}" + f"mariadb -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"' ) self.execute(command) @@ -287,7 +287,7 @@ def revoke_database_access_credentials(self, user, mariadb_root_password): ] for query in queries: command = ( - f"mysql -h {self.host} -uroot -p{mariadb_root_password}" + f"mariadb -h {self.host} -uroot -p{mariadb_root_password}" f' -e "{query}"' ) self.execute(command) @@ -317,7 +317,7 @@ def restore_site_tables(self): output = self.execute( "set -o pipefail && " f"gunzip -c '{backup_file_path}' | " - f"mysql -h {self.host} -u {self.user} -p{self.password} " + f"mariadb -h {self.host} -u {self.user} -p{self.password} " f"{self.database}", executable="/bin/bash", ) @@ -460,7 +460,7 @@ def tablewise_backup(self): ) output = self.execute( "set -o pipefail && " - "mysqldump --single-transaction --quick --lock-tables=false " + "mariadb-dump --single-transaction --quick --lock-tables=false " f"-h {self.host} -u {self.user} -p{self.password} " f"{self.database} '{table}' " f" | gzip > '{backup_file}'", @@ -530,7 +530,7 @@ def restore_touched_tables(self): output = self.execute( "set -o pipefail && " f"gunzip -c '{backup_file}' | " - f"mysql -h {self.host} -u {self.user} -p{self.password} " + f"mariadb -h {self.host} -u {self.user} -p{self.password} " f"{self.database}", executable="/bin/bash", ) @@ -545,7 +545,7 @@ def drop_new_tables(self): data = {"dropped": {}} for table in new_tables: output = self.execute( - f"mysql -h {self.host} -u {self.user} -p{self.password} " + f"mariadb -h {self.host} -u {self.user} -p{self.password} " f"{self.database} -e 'DROP TABLE `{table}`'" ) data["dropped"][table] = output @@ -627,7 +627,7 @@ def timezone(self): ) try: timezone = self.execute( - f"mysql -h {self.host} -u{self.database} -p{self.password} " + f"mariadb -h {self.host} -u{self.database} -p{self.password} " f'-sN -e "{query}"' )["output"].strip() except Exception: @@ -637,7 +637,7 @@ def timezone(self): @property def tables(self): return self.execute( - "mysql --disable-column-names -B -e 'SHOW TABLES' " + "mariadb --disable-column-names -B -e 'SHOW TABLES' " f"-h {self.host} -u {self.user} -p{self.password} {self.database}" )["output"].split("\n") @@ -671,7 +671,7 @@ def optimize_tables(self): for table in tables: query = f"OPTIMIZE TABLE `{table}`" self.execute( - f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" + f"mariadb -sN -h {self.host} -u{self.user} -p{self.password}" f" {self.database} -e '{query}'" ) @@ -747,7 +747,7 @@ def get_database_size(self): " GROUP BY `table_schema`" ) command = ( - f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" + f"mariadb -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'" ) database_size = self.execute(command).get("output") @@ -788,7 +788,7 @@ def get_database_free_size(self): " GROUP BY `table_schema`" ) command = ( - f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" + f"mariadb -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'" ) database_size = self.execute(command).get("output") @@ -809,7 +809,7 @@ def get_database_free_tables(self): " OR `data_free` > 100 * 1024 * 1024)" ) command = ( - f"mysql -sN -h {self.host} -u{self.user} -p{self.password}" + f"mariadb -sN -h {self.host} -u{self.user} -p{self.password}" f" -e '{query}'" ) output = self.execute(command).get("output")