Skip to content

Commit

Permalink
Merge branch 'main' into option-tls-version
Browse files Browse the repository at this point in the history
  • Loading branch information
amjith authored Mar 25, 2024
2 parents 1561834 + 707871a commit f1bd580
Show file tree
Hide file tree
Showing 26 changed files with 820 additions and 133 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ jobs:
linux:
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [
'3.7',
'3.8',
'3.9',
'3.10',
]
include:
- python-version: 3.6
os: ubuntu-18.04 # MySQL 5.7.32
- python-version: 3.7
os: ubuntu-18.04 # MySQL 5.7.32
- python-version: 3.8
os: ubuntu-18.04 # MySQL 5.7.32
- python-version: 3.9
- python-version: '3.7'
os: ubuntu-18.04 # MySQL 5.7.32
- python-version: '3.8'
os: ubuntu-18.04 # MySQL 5.7.32
- python-version: '3.9'
os: ubuntu-20.04 # MySQL 8.0.22
- python-version: '3.10'
os: ubuntu-22.04 # MySQL 8.0.28

runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -61,4 +66,3 @@ jobs:
run: |
coverage combine
coverage report
codecov
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: "12 18 * * 1"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ python ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
.cache/
.coverage
.coverage.*

.venv/
venv/
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ $ sudo apt-get install mycli # Only on debian or ubuntu
--ssh-config-host TEXT Host to connect to ssh server reading from ssh
configuration.

--ssl Enable SSL for connection (automatically
enabled with other flags).
--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 @@ -136,6 +138,7 @@ Features
* Log every query and its results to a file (disabled by default).
* Pretty prints tabular data (with colors!)
* Support for SSL connections
* Some features are only exposed as [key bindings](doc/key_bindings.rst)

Contributions:
--------------
Expand Down Expand Up @@ -220,7 +223,7 @@ Thanks to [PyMysql](https://github.com/PyMySQL/PyMySQL) for a pure python adapte

### Compatibility

Mycli is tested on macOS and Linux.
Mycli is tested on macOS and Linux, and requires Python 3.7 or better.

**Mycli is not tested on Windows**, but the libraries used in this app are Windows-compatible.
This means it should work without any modifications. If you're unable to run it
Expand Down
59 changes: 57 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
Upcoming
========


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

* Don't install tests.
* Do not ignore the socket passed with the -S option, even when no port is passed
* Fix unexpected exception when using dsn without username & password (Thanks: [Will Wang])
* Let the `--prompt` option act normally with its predefined default value



Internal:
---------
* paramiko is newer than 2.11.0 now, remove version pinning `cryptography`.


1.27.0 (2023/08/11)
===================

Features:
---------

* Detect TiDB instance, show in the prompt, and use additional keywords.
* Fix the completion order to show more commonly-used keywords at the top.

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

* Better handle empty statements in un/prettify
* Remove vi-mode bindings for prettify/unprettify.
* Honor `\G` when executing from commandline with `-e`.
* Correctly report the version of TiDB.
* Revised `botton` spelling mistakes with `bottom` in `mycli/clitoolbar.py`


1.26.1 (2022/09/01)
===================

Bug Fixes:
----------
* Require Python 3.7 in `setup.py`


1.26.0 (2022/09/01)
===================

Features:
---------

* Add `--ssl` flag to enable ssl/tls.
* Add `pager` option to `~/.myclirc`, for instance `pager = 'pspg --csv'` (Thanks: [BuonOmo])
* Add prettify/unprettify keybindings to format the current statement using `sqlglot`.

TBD
===

Features:
---------
Expand Down Expand Up @@ -894,6 +947,7 @@ Bug Fixes:

[Amjith Ramanujam]: https://blog.amjith.com
[Artem Bezsmertnyi]: https://github.com/mrdeathless
[BuonOmo]: https://github.com/BuonOmo
[Carlos Afonso]: https://github.com/afonsocarlos
[Casper Langemeijer]: https://github.com/langemeijer
[Daniel West]: http://github.com/danieljwest
Expand All @@ -920,3 +974,4 @@ Bug Fixes:
[William GARCIA]: https://github.com/willgarcia
[xeron]: https://github.com/xeron
[Zach DeCook]: https://zachdecook.com
[Will Wang]: https://github.com/willww64
65 changes: 65 additions & 0 deletions doc/key_bindings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
*************
Key Bindings:
*************

Most key bindings are simply inherited from `prompt-toolkit <https://python-prompt-toolkit.readthedocs.io/en/master/index.html>`_ .

The following key bindings are special to mycli:

###
F2
###

Enable/Disable SmartCompletion Mode.

###
F3
###

Enable/Disable Multiline Mode.

###
F4
###

Toggle between Vi and Emacs mode.

###
Tab
###

Force autocompletion at cursor.

#######
C-space
#######

Initialize autocompletion at cursor.

If the autocompletion menu is not showing, display it with the appropriate completions for the context.

If the menu is showing, select the next completion.

#########
ESC Enter
#########

Introduce a line break in multi-line mode, or dispatch the command in single-line mode.

The sequence ESC-Enter is often sent by Alt-Enter.

##################
C-x p (Emacs-mode)
##################

Prettify and indent current statement, usually into multiple lines.

Only accepts buffers containing single SQL statements.

##################
C-x u (Emacs-mode)
##################

Unprettify and dedent current statement, usually into one line.

Only accepts buffers containing single SQL statements.
14 changes: 9 additions & 5 deletions mycli/AUTHORS
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
Project Lead:
-------------
* Thomas Roten


Core Developers:
----------------

* Thomas Roten
* Irina Truong
* Matheus Rosa
* Darik Gamble
Expand All @@ -24,6 +20,7 @@ Contributors:
* Artem Bezsmertnyi
* bitkeen
* bjarnagin
* BuonOmo
* caitinggui
* Carlos Afonso
* Casper Langemeijer
Expand All @@ -34,6 +31,7 @@ Contributors:
* Daniel Black
* Daniel West
* Daniël van Eeden
* Fabrizio Gennari
* François Pietka
* Frederic Aoustin
* Georgy Frolov
Expand Down Expand Up @@ -93,6 +91,12 @@ Contributors:
* Arvind Mishra
* Kevin Schmeichel
* Mel Dafert
* Thomas Copper
* Will Wang
* Alfred Wingate
* Zhanze Wang
* Houston Wong


Created by:
-----------
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.25.0'
__version__ = '1.27.0'
10 changes: 7 additions & 3 deletions mycli/clitoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
def create_toolbar_tokens_func(mycli, show_fish_help):
"""Return a function that generates the toolbar tokens."""
def get_toolbar_tokens():
result = []
result.append(('class:bottom-toolbar', ' '))
result = [('class:bottom-toolbar', ' ')]

if mycli.multi_line:
delimiter = special.get_current_delimiter()
Expand All @@ -26,10 +25,15 @@ def get_toolbar_tokens():
'[F3] Multiline: OFF '))
if mycli.prompt_app.editing_mode == EditingMode.VI:
result.append((
'class:botton-toolbar.on',
'class:bottom-toolbar.on',
'Vi-mode ({})'.format(_get_vi_mode())
))

if mycli.toolbar_error_message:
result.append(
('class:bottom-toolbar', ' ' + mycli.toolbar_error_message))
mycli.toolbar_error_message = None

if show_fish_help():
result.append(
('class:bottom-toolbar', ' Right-arrow to complete suggestion'))
Expand Down
9 changes: 8 additions & 1 deletion mycli/completion_refresher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import OrderedDict

from .sqlcompleter import SQLCompleter
from .sqlexecute import SQLExecute
from .sqlexecute import SQLExecute, ServerSpecies

class CompletionRefresher(object):

Expand Down Expand Up @@ -113,6 +113,8 @@ def refresh_users(completer, executor):
@refresher('functions')
def refresh_functions(completer, executor):
completer.extend_functions(executor.functions())
if executor.server_info.species == ServerSpecies.TiDB:
completer.extend_functions(completer.tidb_functions, builtin=True)

@refresher('special_commands')
def refresh_special(completer, executor):
Expand All @@ -121,3 +123,8 @@ def refresh_special(completer, executor):
@refresher('show_commands')
def refresh_show_commands(completer, executor):
completer.extend_show_items(executor.show_candidates())

@refresher('keywords')
def refresh_keywords(completer, executor):
if executor.server_info.species == ServerSpecies.TiDB:
completer.extend_keywords(completer.tidb_keywords, replace=True)
Loading

0 comments on commit f1bd580

Please sign in to comment.