Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add support for special commands in favorite queries. #600

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions mycli/packages/special/iocommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from configobj import ConfigObj

from . import export
from .main import special_command, NO_QUERY, PARSED_QUERY
from .main import (CommandNotFound, execute, special_command, NO_QUERY,
PARSED_QUERY)
from .favoritequeries import FavoriteQueries
from .utils import handle_cd_command
from mycli.packages.prompt_utils import confirm_destructive_query
Expand Down Expand Up @@ -186,7 +187,13 @@ def execute_favorite_query(cur, arg, **_):
for sql in sqlparse.split(query):
sql = sql.rstrip(';')
title = '> %s' % (sql)
cur.execute(sql)
try: # Special command
_logger.debug('Trying a dbspecial command. sql: %r', sql)
for result in execute(cur, sql):
yield result
except CommandNotFound: # Regular SQL
_logger.debug('Regular sql statement. sql: %r', sql)
cur.execute(sql)
if cur.description:
headers = [x[0] for x in cur.description]
yield (title, cur, headers, None)
Expand Down