(
self,
sqlexecute: SQLExecute | None = None,
prompt: str | None = None,
toolbar_format: str | None = None,
logfile: TextIOWrapper | Literal[False] | None = None,
login_path: str | None = None,
auto_vertical_output: bool = False,
warn: bool | None = None,
myclirc: str = "~/.myclirc",
show_warnings: bool | None = None,
cli_verbosity: int = 0,
)
| 62 | ] |
| 63 | |
| 64 | def __init__( |
| 65 | self, |
| 66 | sqlexecute: SQLExecute | None = None, |
| 67 | prompt: str | None = None, |
| 68 | toolbar_format: str | None = None, |
| 69 | logfile: TextIOWrapper | Literal[False] | None = None, |
| 70 | login_path: str | None = None, |
| 71 | auto_vertical_output: bool = False, |
| 72 | warn: bool | None = None, |
| 73 | myclirc: str = "~/.myclirc", |
| 74 | show_warnings: bool | None = None, |
| 75 | cli_verbosity: int = 0, |
| 76 | ) -> None: |
| 77 | self.sqlexecute = sqlexecute |
| 78 | self.logfile = logfile |
| 79 | self.login_path = login_path |
| 80 | self.toolbar_error_message: str | None = None |
| 81 | self.prompt_session: PromptSession | None = None |
| 82 | self._keepalive_counter = 0 |
| 83 | self.keepalive_ticks: int | None = 0 |
| 84 | self.sandbox_mode: bool = False |
| 85 | self.checkpoint: IO | None = None |
| 86 | |
| 87 | # Load config. |
| 88 | config_files: list[str | IO[str]] = self.system_config_files + [myclirc] |
| 89 | |
| 90 | c = self.config = read_config_files(config_files) |
| 91 | # only needed in --checkup mode. todo: only load when needed |
| 92 | self.config_without_package_defaults = read_config_files(config_files, ignore_package_defaults=True) |
| 93 | # only needed in --checkup mode. todo: only load when needed |
| 94 | self.config_without_user_options = read_config_files(config_files, ignore_user_options=True) |
| 95 | self.multi_line = c["main"].as_bool("multi_line") |
| 96 | self.key_bindings = c["main"]["key_bindings"] |
| 97 | self.emacs_ttimeoutlen = c['keys'].as_float('emacs_ttimeoutlen') |
| 98 | self.vi_ttimeoutlen = c['keys'].as_float('vi_ttimeoutlen') |
| 99 | special.set_timing_enabled(c["main"].as_bool("timing")) |
| 100 | special.set_show_favorite_query(c["main"].as_bool("show_favorite_query")) |
| 101 | if show_warnings is not None: |
| 102 | special.set_show_warnings_enabled(show_warnings) |
| 103 | else: |
| 104 | special.set_show_warnings_enabled(c['main'].as_bool('show_warnings')) |
| 105 | self.beep_after_seconds = float(c["main"]["beep_after_seconds"] or 0) |
| 106 | self.default_keepalive_ticks = c['connection'].as_int('default_keepalive_ticks') |
| 107 | |
| 108 | FavoriteQueries.instance = FavoriteQueries.from_config(self.config) |
| 109 | |
| 110 | self.dsn_alias: str | None = None |
| 111 | self.main_formatter = TabularOutputFormatter(format_name=c["main"]["table_format"]) |
| 112 | self.redirect_formatter = TabularOutputFormatter(format_name=c["main"].get("redirect_format", "csv")) |
| 113 | sql_format.register_new_formatter(self.main_formatter) |
| 114 | sql_format.register_new_formatter(self.redirect_formatter) |
| 115 | self.main_formatter.mycli = self |
| 116 | self.redirect_formatter.mycli = self |
| 117 | self.syntax_style = c["main"]["syntax_style"] |
| 118 | self.verbosity = -1 if c["main"].as_bool("less_chatty") else 0 |
| 119 | if cli_verbosity: |
| 120 | self.verbosity = cli_verbosity |
| 121 | self.cli_style = c["colors"] |
nothing calls this directly
no test coverage detected