mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #22646: Added support for the MySQL ssl-ca option to dbshell.
This commit is contained in:
@@ -6,14 +6,15 @@ from django.db.backends import BaseDatabaseClient
|
||||
class DatabaseClient(BaseDatabaseClient):
|
||||
executable_name = 'mysql'
|
||||
|
||||
def runshell(self):
|
||||
settings_dict = self.connection.settings_dict
|
||||
args = [self.executable_name]
|
||||
@classmethod
|
||||
def settings_to_cmd_args(cls, settings_dict):
|
||||
args = [cls.executable_name]
|
||||
db = settings_dict['OPTIONS'].get('db', settings_dict['NAME'])
|
||||
user = settings_dict['OPTIONS'].get('user', settings_dict['USER'])
|
||||
passwd = settings_dict['OPTIONS'].get('passwd', settings_dict['PASSWORD'])
|
||||
host = settings_dict['OPTIONS'].get('host', settings_dict['HOST'])
|
||||
port = settings_dict['OPTIONS'].get('port', settings_dict['PORT'])
|
||||
cert = settings_dict['OPTIONS'].get('ssl', {}).get('ca')
|
||||
defaults_file = settings_dict['OPTIONS'].get('read_default_file')
|
||||
# Seems to be no good way to set sql_mode with CLI.
|
||||
|
||||
@@ -30,7 +31,12 @@ class DatabaseClient(BaseDatabaseClient):
|
||||
args += ["--host=%s" % host]
|
||||
if port:
|
||||
args += ["--port=%s" % port]
|
||||
if cert:
|
||||
args += ["--ssl-ca=%s" % cert]
|
||||
if db:
|
||||
args += [db]
|
||||
return args
|
||||
|
||||
def runshell(self):
|
||||
args = DatabaseClient.settings_to_cmd_args(self.connection.settings_dict)
|
||||
subprocess.call(args)
|
||||
|
||||
Reference in New Issue
Block a user