MCPcopy
hub / github.com/dbcli/pgcli / _evaluate_command

Method _evaluate_command

pgcli/main.py:1129–1228  ·  view source on GitHub ↗

Used to run a command entered by the user during CLI operation (Puts the E in REPL) returns (results, MetaQuery)

(self, text)

Source from the content-addressed store, hash-verified

1127 return new_cur, new_status
1128
1129 def _evaluate_command(self, text):
1130 """Used to run a command entered by the user during CLI operation
1131 (Puts the E in REPL)
1132
1133 returns (results, MetaQuery)
1134 """
1135 logger = self.logger
1136 logger.debug("sql: %r", text)
1137
1138 # set query to formatter in order to parse table name
1139 self.formatter.query = text
1140 all_success = True
1141 meta_changed = False # CREATE, ALTER, DROP, etc
1142 mutated = False # INSERT, DELETE, etc
1143 db_changed = False
1144 path_changed = False
1145 output = []
1146 total = 0
1147 execution = 0
1148
1149 # Run the query.
1150 start = time()
1151 on_error_resume = self.on_error == "RESUME"
1152 res = self.pgexecute.run(
1153 text,
1154 self.pgspecial,
1155 lambda x: exception_formatter(x, self.verbose_errors),
1156 on_error_resume,
1157 explain_mode=self.explain_mode,
1158 )
1159
1160 is_special = None
1161
1162 for title, cur, headers, status, sql, success, is_special in res:
1163 logger.debug("headers: %r", headers)
1164 logger.debug("rows: %r", cur)
1165 logger.debug("status: %r", status)
1166
1167 if self._should_limit_output(sql, cur):
1168 cur, status = self._limit_output(cur)
1169
1170 if self.pgspecial.auto_expand or self.auto_expand:
1171 max_width = self.prompt_app.output.get_size().columns
1172 else:
1173 max_width = None
1174
1175 expanded = self.pgspecial.expanded_output or self.expanded_output
1176 settings = OutputSettings(
1177 table_format=self.table_format,
1178 dcmlfmt=self.decimal_format,
1179 floatfmt=self.float_format,
1180 column_date_formats=self.column_date_formats,
1181 missingval=self.null_string,
1182 expanded=expanded,
1183 max_width=max_width,
1184 case_function=(self.completer.case if self.settings["case_column_headers"] else lambda x: x),
1185 style_output=self.style_output,
1186 max_field_width=self.max_field_width,

Callers 2

execute_commandMethod · 0.95

Calls 10

_should_limit_outputMethod · 0.95
_limit_outputMethod · 0.95
format_outputFunction · 0.85
is_mutatingFunction · 0.85
has_change_db_cmdFunction · 0.85
has_meta_cmdFunction · 0.85
has_change_path_cmdFunction · 0.85
exception_formatterFunction · 0.70
runMethod · 0.45

Tested by 1