MCPcopy Create free account
hub / github.com/dbcli/mycli / _one_iteration

Function _one_iteration

mycli/main_modes/repl.py:593–806  ·  view source on GitHub ↗
(
    mycli: 'MyCli',
    state: ReplState,
    text: str | None = None,
)

Source from the content-addressed store, hash-verified

591
592
593def _one_iteration(
594 mycli: 'MyCli',
595 state: ReplState,
596 text: str | None = None,
597) -> None:
598 sqlexecute = mycli.sqlexecute
599 assert sqlexecute is not None
600
601 inputhook = partial(_keepalive_hook, mycli) if mycli.keepalive_ticks and mycli.keepalive_ticks >= 1 else None
602
603 if text is None:
604 try:
605 assert mycli.prompt_session is not None
606 loaded_message_fn = partial(_get_prompt_message, mycli, mycli.prompt_session.app)
607 text = mycli.prompt_session.prompt(
608 inputhook=inputhook,
609 message=loaded_message_fn,
610 )
611 except KeyboardInterrupt:
612 return
613
614 special.set_expanded_output(False)
615 special.set_forced_horizontal_output(False)
616
617 try:
618 text = handle_editor_command(
619 mycli,
620 text,
621 inputhook,
622 loaded_message_fn,
623 )
624 except RuntimeError as e:
625 mycli.logger.error('sql: %r, error: %r', text, e)
626 mycli.logger.error('traceback: %r', traceback.format_exc())
627 mycli.echo(str(e), err=True, fg='red')
628 return
629
630 try:
631 if handle_clip_command(mycli, text):
632 return
633 except RuntimeError as e:
634 mycli.logger.error('sql: %r, error: %r', text, e)
635 mycli.logger.error('traceback: %r', traceback.format_exc())
636 mycli.echo(str(e), err=True, fg='red')
637 return
638
639 while special.is_llm_command(text):
640 start = time.time()
641 try:
642 assert sqlexecute.conn is not None
643 cur = sqlexecute.conn.cursor()
644 context, sql, duration = special.handle_llm(
645 text,
646 cur,
647 sqlexecute.dbname or '',
648 mycli.llm_prompt_field_truncate,
649 mycli.llm_prompt_section_truncate,
650 )

Callers 1

main_replFunction · 0.85

Calls 15

handle_editor_commandFunction · 0.90
handle_clip_commandFunction · 0.90
is_redirect_commandFunction · 0.90
get_redirect_componentsFunction · 0.90
is_sandbox_allowedFunction · 0.90
is_password_changeFunction · 0.90
extract_new_passwordFunction · 0.90
is_dropping_databaseFunction · 0.90
need_completion_refreshFunction · 0.90
need_completion_resetFunction · 0.90
_output_resultsFunction · 0.85

Tested by

no test coverage detected