Git Product home page Git Product logo

mitzasql's Introduction

Build Status Coverage Status License: MIT PyPI version

About

MitzaSQL is a free Python3 TUI MySQL client for Linux which aims to provide an easy-to-use console alternative to GUI clients. It is not meant to be a full-fledged GUI client, it only provides a read-only view of the database, though you can manipulate the data by using raw SQL queries. Some of the main features are:

  • Manage multiple sessions
  • View databases
  • View list of tables, sql views & stored procedures in a database
  • View rows in a table or sql view:
  • Easily sort table data
  • Filter table data using VIM-like commands (:like, :gt, :lt, :in...)
  • SQL Query editor with syntax highlighting, smart autocomplete and clipboard support (optional dependency needs to be installed)
  • VIM style keyboard shortcuts
  • VIM style commands with autocomplete support
  • Macros support

MitzaSQL is heavily inspired by HeidiSQL and is licensed under MIT. The lexer's tokens implementation uses code from python-sqlparse project.

Demo

asciicast

Website

https://vladbalmos.github.io/mitzasql

System requirements

  • Linux
  • Python3 (3.6 - 3.9)
  • MySQL (5.6 - 8)

Security

By default MitzaSQL stores connection credentials in plain text files in your home directory. If security is a concern you could store the file in an encrypted partition/directory and specify the path to the session file when the program starts using the --sessions_file /path/to/sessions.ini flag. Another option would be not to persist the connection credentials when creating a new session.

Performance & known issues

Loading large datasets will slow down the rendering. By default, when opening a table screen only the first 100 records are loaded. The rest of the data is loaded automatically when scrolling down. When running queries with the SQL Query editor make sure you don't load a large number of records or else your user experience might suffer.

Dependencies

  • urwid
  • mysql-connector-python
  • appdirs
  • pygments

Installation

pip3 install mitzasql

If you require clipboard support you need to install the extra dependency:

pip3 install mitzasql[clipboard]

This will install the pyperclip module. Keep in mind that pyperclip requires xclip/xsel to be installed on Linux, or the gtk/qt python modules.

Development

Dependencies

  • tox
  • Docker (optional)
  • docker-compose (optional)

Docker is only required for running the integration tests, testing during feature development can be done with tox alone (see below).

Running the development version

# If your currently installed Python version != 3.6 use TOXENV to specify it
tox -e dev
source .tox/dev/bin/activate
mitzasql

To run the program using a different Python version using Docker:

./run-in-docker.sh [python version] [mysql version]
# ./run-in-docker.sh 36 mysql55
tox -e dev
source .tox/dev/bin/activate
mitzasql

Tests

The testing process uses tox & Docker to automate running the tests against multiple versions of Python and MySQL servers.

During feature development Docker is not really necessary, I use it to run the test MySQL server but it that can be installed directly on the host. If that is the case, then new connection details have to be specified using environmental variables (see tests/db/connection_fixture.py for more details).

To run the tests during feature development run:

cp env.template .env # necessary if using Docker
docker-compose up # necessary if using Docker
tox

To generate code coverage:

./coverage.sh

Code coverage is generated in the htmlcov directory.

Integration testing

See test-mitzasql.sh for more info.

UI testing

See test-mitzasql-ui.sh for more info.

mitzasql's People

Contributors

dependabot[bot] avatar oliverseal avatar vladbalmos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mitzasql's Issues

Implement query editor autocomplete

The suggestions are based on:

  • the existing mysql keywords
  • columns in active table
  • strings entered previously in other queries

The suggestions will be displayed in a status bar widget attached to the bottom of the editor

Implement basic mysql filtering commands

:like [column] keyword => WHERE col LIKE "%keyword%"
:llike [column] keyword => WHERE col LIKE "%keyword"
:rlike [column] keyword => WHERE col LIKE "keyword%"
:eq column value
:lt column value
:lte column value
:gt column value
:gte column value
:in column v1, v2, v2
:between column v1, v2
:null column

Command ending in !, will be negated. Ex: between! col v1, ve => where col not between v1 and v2

Cache db views widgets

When refreshing the widget, if the model params != from existing ones, replace the model & table view, making sure that any install signal handlers are disconnected first

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.