Skip to content

Commit

Permalink
Merge branch 'master' into reuse-ssh-connection
Browse files Browse the repository at this point in the history
  • Loading branch information
pasenor committed Feb 14, 2021
2 parents 664e62c + bb5b529 commit deff68f
Show file tree
Hide file tree
Showing 29 changed files with 455 additions and 110 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: mycli

on:
pull_request:
paths-ignore:
- '**.md'

jobs:
linux:

runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

steps:

- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Start MySQL
run: |
sudo /etc/init.d/mysql start
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install --no-cache-dir -e .
- name: Wait for MySQL connection
run: |
while ! mysqladmin ping --host=localhost --port=3306 --user=root --password=root --silent; do
sleep 5
done
- name: Pytest / behave
env:
PYTEST_PASSWORD: root
run: |
./setup.py test --pytest-args="--cov-report= --cov=mycli"
- name: Lint
run: |
./setup.py lint --branch=HEAD
- name: Coverage
run: |
coverage combine
coverage report
codecov
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ $ sudo apt-get install mycli # Only on debian or ubuntu
--ssh-password TEXT Password to connect to ssh server.
--ssh-key-filename TEXT Private key filename (identify file) for the
ssh connection.
--ssh-config-path TEXT Path to ssh configuation.
--ssh-config-host TEXT Host for ssh server in ssh configuations (requires paramiko).
--ssh-config-path TEXT Path to ssh configuration.
--ssh-config-host TEXT Host for ssh server in ssh configurations (requires paramiko).
--ssl-ca PATH CA file in PEM format.
--ssl-capath TEXT CA directory.
--ssl-cert PATH X509 cert in PEM format.
Expand Down Expand Up @@ -97,6 +97,7 @@ $ sudo apt-get install mycli # Only on debian or ubuntu
--login-path TEXT Read this path from the login file.
-e, --execute TEXT Execute command and quit.
--init-command TEXT SQL statement to execute after connecting.
--charset TEXT Character set for MySQL session.
--help Show this message and exit.

Features
Expand All @@ -113,7 +114,7 @@ Features
* Support for multiline queries.
* Favorite queries with optional positional parameters. Save a query using
`\fs alias query` and execute it with `\f alias` whenever you need.
* Timing of sql statments and table rendering.
* Timing of sql statements and table rendering.
* Config file is automatically created at ``~/.myclirc`` at first launch.
* Log every query and its results to a file (disabled by default).
* Pretty prints tabular data (with colors!)
Expand Down
56 changes: 54 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,68 @@
TBD
=======

Bug Fixes:
----------
* Allow `FileNotFound` exception for SSH config files.

Features:
---------
* Add `-g` shortcut to option `--login-path`.
* Reuse the same SSH connection for both main thread and completion thread.


1.23.2
===

Bug Fixes:
----------
* Ensure `--port` is always an int.

1.23.1
===

Bug Fixes:
----------
* Allow `--host` without `--port` to make a TCP connection.

1.23.0
===

Bug Fixes:
----------
* Fix config file include logic

Features:
---------

* Add an option `--init-command` to execute SQL after connecting (Thanks: [KITAGAWA Yasutaka]).
* Reuse the same SSH connection in both main thread and completion thread (Thanks: [Georgy Frolov]).
* Use InputMode.REPLACE_SINGLE
* Add support for ANSI escape sequences for coloring the prompt.
* Allow customization of Pygments SQL syntax-highlighting styles.
* Add a `\clip` special command to copy queries to the system clipboard.
* Add a special command `\pipe_once` to pipe output to a subprocess.
* Add an option `--charset` to set the default charset when connect database.

Bug Fixes:
----------
* Fixed compatibility with sqlparse 0.4 (Thanks: [mtorromeo]).
* Fixed iPython magic (Thanks: [mwcm]).
* Send "Connecting to socket" message to the standard error.
* Respect empty string for prompt_continuation via `prompt_continuation = ''` in `.myclirc`
* Fix \once -o to overwrite output whole, instead of line-by-line.
* Dispatch lines ending with `\e` or `\clip` on return, even in multiline mode.
* Restore working local `--socket=<UDS>` (Thanks: [xeron]).
* Allow backtick quoting around the database argument to the `use` command.
* Avoid opening `/dev/tty` when `--no-warn` is given.
* Fixed some typo errors in `README.md`.

1.22.2
======

Bug Fixes:
----------

* Make the `pwd` module optional.
* Make the `pwd` module optional.

1.22.1
======
Expand Down Expand Up @@ -787,3 +836,6 @@ Bug Fixes:
[Zach DeCook]: https://zachdecook.com
[laixintao]: https://github.com/laixintao
[Nathan Huang]: https://github.com/hxueh
[mtorromeo]: https://github.com/mtorromeo
[mwcm]: https://github.com/mwcm
[xeron]: https://github.com/xeron
9 changes: 9 additions & 0 deletions mycli/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ Contributors:
* Zach DeCook
* kevinhwang91
* KITAGAWA Yasutaka
* Nicolas Palumbo
* Andy Teijelo Pérez
* bitkeen
* Morgan Mitchell
* Massimiliano Torromeo
* Roland Walker
* xeron
* 0xflotus
* Seamile

Creator:
--------
Expand Down
2 changes: 1 addition & 1 deletion mycli/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.22.2'
__version__ = '1.23.2'
2 changes: 2 additions & 0 deletions mycli/clibuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def _multiline_exception(text):

text.endswith('\\g') or
text.endswith('\\G') or
text.endswith(r'\e') or
text.endswith(r'\clip') or

# Exit doesn't need semi-column`
(text == 'exit') or
Expand Down
33 changes: 33 additions & 0 deletions mycli/clistyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,36 @@
v: k for k, v in TOKEN_TO_PROMPT_STYLE.items()
}

# all tokens that the Pygments MySQL lexer can produce
OVERRIDE_STYLE_TO_TOKEN = {
'sql.comment': Token.Comment,
'sql.comment.multi-line': Token.Comment.Multiline,
'sql.comment.single-line': Token.Comment.Single,
'sql.comment.optimizer-hint': Token.Comment.Special,
'sql.escape': Token.Error,
'sql.keyword': Token.Keyword,
'sql.datatype': Token.Keyword.Type,
'sql.literal': Token.Literal,
'sql.literal.date': Token.Literal.Date,
'sql.symbol': Token.Name,
'sql.quoted-schema-object': Token.Name.Quoted,
'sql.quoted-schema-object.escape': Token.Name.Quoted.Escape,
'sql.constant': Token.Name.Constant,
'sql.function': Token.Name.Function,
'sql.variable': Token.Name.Variable,
'sql.number': Token.Number,
'sql.number.binary': Token.Number.Bin,
'sql.number.float': Token.Number.Float,
'sql.number.hex': Token.Number.Hex,
'sql.number.integer': Token.Number.Integer,
'sql.operator': Token.Operator,
'sql.punctuation': Token.Punctuation,
'sql.string': Token.String,
'sql.string.double-quouted': Token.String.Double,
'sql.string.escape': Token.String.Escape,
'sql.string.single-quoted': Token.String.Single,
'sql.whitespace': Token.Text,
}

def parse_pygments_style(token_name, style_object, style_dict):
"""Parse token type and style string.
Expand Down Expand Up @@ -108,6 +138,9 @@ def style_factory_output(name, cli_style):
elif token in PROMPT_STYLE_TO_TOKEN:
token_type = PROMPT_STYLE_TO_TOKEN[token]
style.update({token_type: cli_style[token]})
elif token in OVERRIDE_STYLE_TO_TOKEN:
token_type = OVERRIDE_STYLE_TO_TOKEN[token]
style.update({token_type: cli_style[token]})
else:
# TODO: cli helpers will have to switch to ptk.Style
logger.error('Unhandled style / class name: %s', token)
Expand Down
1 change: 1 addition & 0 deletions mycli/clitoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ def _get_vi_mode():
InputMode.INSERT: 'I',
InputMode.NAVIGATION: 'N',
InputMode.REPLACE: 'R',
InputMode.REPLACE_SINGLE: 'R',
InputMode.INSERT_MULTIPLE: 'M',
}[get_app().vi_state.input_mode]
2 changes: 1 addition & 1 deletion mycli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def str_to_bool(s):
elif s.lower() in false_values:
return False
else:
raise ValueError('not a recognized boolean value: %s'.format(s))
raise ValueError('not a recognized boolean value: {0}'.format(s))


def strip_matching_quotes(s):
Expand Down
2 changes: 1 addition & 1 deletion mycli/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def load_ipython_extension(ipython):
def mycli_line_magic(line):
_logger.debug('mycli magic called: %r', line)
parsed = sql.parse.parse(line, {})
conn = sql.connection.Connection.get(parsed['connection'])
conn = sql.connection.Connection(parsed['connection'])

try:
# A corresponding mycli object already exists
Expand Down
Loading

0 comments on commit deff68f

Please sign in to comment.