From 8f20e5e00d6071ce138e0dacb1437b55e3175965 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Wed, 29 Apr 2020 11:44:58 +0530 Subject: [PATCH] chore: escape backticks on db commands Signed-off-by: Chinmay D. Pai --- build/common/commands/new.py | 2 +- build/common/commands/restore_backup.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/common/commands/new.py b/build/common/commands/new.py index 0db5616c..82c0ab7b 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -73,7 +73,7 @@ def main(): os.system(command) # Grant permission to database - command = mysql_command + "\"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;\"".format( + command = mysql_command + "\"GRANT ALL PRIVILEGES ON \`{db_name}\`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;\"".format( db_name=site_config.get('db_name') ) os.system(command) diff --git a/build/common/commands/restore_backup.py b/build/common/commands/restore_backup.py index 341849cd..1c098157 100644 --- a/build/common/commands/restore_backup.py +++ b/build/common/commands/restore_backup.py @@ -60,13 +60,13 @@ def restore_database(files_base, site): ) # drop db if exists for clean restore - drop_database = mysql_command + "\"DROP DATABASE IF EXISTS `{db_name}`;\"".format( + drop_database = mysql_command + "\"DROP DATABASE IF EXISTS \`{db_name}\`;\"".format( db_name=site_config.get('db_name') ) os.system(drop_database) # create db - create_database = mysql_command + "\"CREATE DATABASE IF NOT EXISTS `{db_name}`;\"".format( + create_database = mysql_command + "\"CREATE DATABASE IF NOT EXISTS \`{db_name}\`;\"".format( db_name=site_config.get('db_name') ) os.system(create_database) @@ -86,7 +86,7 @@ def restore_database(files_base, site): os.system(set_user_password) # grant db privileges to user - grant_privileges = mysql_command + "\"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;\"".format( + grant_privileges = mysql_command + "\"GRANT ALL PRIVILEGES ON \`{db_name}\`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;\"".format( db_name=site_config.get('db_name') ) os.system(grant_privileges)