(self, arg: str, **_)
| 120 | yield SQLResult(status=msg) |
| 121 | |
| 122 | def change_db(self, arg: str, **_) -> Generator[SQLResult, None, None]: |
| 123 | if arg.startswith("`") and arg.endswith("`"): |
| 124 | arg = re.sub(r"^`(.*)`$", r"\1", arg) |
| 125 | arg = re.sub(r"``", r"`", arg) |
| 126 | |
| 127 | if not arg: |
| 128 | click.secho("No database selected", err=True, fg="red") |
| 129 | return |
| 130 | |
| 131 | assert isinstance(self.sqlexecute, SQLExecute) |
| 132 | |
| 133 | if self.sqlexecute.dbname == arg: |
| 134 | msg = f'You are already connected to database "{self.sqlexecute.dbname}" as user "{self.sqlexecute.user}"' |
| 135 | else: |
| 136 | self.sqlexecute.change_db(arg) |
| 137 | msg = f'You are now connected to database "{self.sqlexecute.dbname}" as user "{self.sqlexecute.user}"' |
| 138 | |
| 139 | # todo: this jump back to repl.py is a sign that separation is incomplete. |
| 140 | # also: it should not be needed. Don't titles update on every new prompt? |
| 141 | set_all_external_titles(cast(Any, self)) |
| 142 | |
| 143 | yield SQLResult(status=msg) |
| 144 | |
| 145 | def execute_from_file(self, arg: str, **_) -> Iterable[SQLResult]: |
| 146 | if not arg: |
no test coverage detected