|
4 | 4 |
|
5 | 5 |
|
6 | 6 | class DatabaseClient(BaseDatabaseClient):
|
7 |
| - executable_name = "mongo" |
| 7 | + executable_name = "mongosh" |
8 | 8 |
|
9 | 9 | @classmethod
|
10 |
| - def settings_to_cmd_args_env(cls, settings_dict, parameters): |
11 |
| - raise NotImplementedError |
| 10 | + def settings_to_cmd_args_env(cls, settings_dict, parameters): # noqa: ARG003 parameters unused |
| 11 | + options = settings_dict.get("OPTIONS", {}) |
| 12 | + args = [cls.executable_name] |
| 13 | + |
| 14 | + host = settings_dict["HOST"] |
| 15 | + port = settings_dict["PORT"] |
| 16 | + dbname = settings_dict["NAME"] |
| 17 | + user = settings_dict["USER"] |
| 18 | + passwd = settings_dict["PASSWORD"] |
| 19 | + auth_database = options.get("authSource") |
| 20 | + auth_mechanism = options.get("authMechanism") |
| 21 | + retry_writes = options.get("retryWrites") |
| 22 | + |
| 23 | + if host: |
| 24 | + args += ["--host", host] |
| 25 | + if port: |
| 26 | + args += ["--port", port] |
| 27 | + if user: |
| 28 | + args += ["--username", user] |
| 29 | + if passwd: |
| 30 | + args += ["--password", passwd] |
| 31 | + if auth_database: |
| 32 | + args += ["--authenticationDatabase", auth_database] |
| 33 | + if auth_mechanism: |
| 34 | + args += ["--authenticationMechanism", auth_mechanism] |
| 35 | + if retry_writes is not None: |
| 36 | + args += ["--retryWrites", str(retry_writes).lower()] |
| 37 | + |
| 38 | + args.append(dbname) |
| 39 | + |
| 40 | + return args, None |
12 | 41 |
|
13 | 42 | def runshell(self, parameters):
|
14 | 43 | sigint_handler = signal.getsignal(signal.SIGINT)
|
|
0 commit comments