Skip to content

Commit

Permalink
fix: Use mariadb commands instead of mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
cogk committed Sep 10, 2024
1 parent bbc3617 commit ad281f5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions agent/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,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)
Expand All @@ -283,7 +283,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)
Expand Down
2 changes: 1 addition & 1 deletion agent/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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}'"
Expand Down
2 changes: 1 addition & 1 deletion agent/proxysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'"
)
Expand Down
24 changes: 12 additions & 12 deletions agent/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,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)
Expand All @@ -288,7 +288,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)
Expand Down Expand Up @@ -318,7 +318,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",
)
Expand Down Expand Up @@ -474,7 +474,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}'",
Expand Down Expand Up @@ -544,7 +544,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",
)
Expand All @@ -559,7 +559,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
Expand Down Expand Up @@ -641,7 +641,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'--connect-timeout 3 -sN -e "{query}"'
)["output"].strip()
except Exception:
Expand All @@ -651,7 +651,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")

Expand Down Expand Up @@ -685,7 +685,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}'"
)

Expand Down Expand Up @@ -761,7 +761,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")
Expand Down Expand Up @@ -810,7 +810,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")
Expand All @@ -831,7 +831,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")
Expand Down

0 comments on commit ad281f5

Please sign in to comment.