Skip to main content

A MySQL client to run queries, write execution reports and export results

Project description

mysql_tracer

A MySQL client to run queries, write execution reports and export results.

It is made with the purpose to support SELECT statements only. Other statements will work but the features offered by this module will provide little help or make no sense.

Usage

This can be used as a command line tool:

$ python3 mysql_tracer -h
usage: mysql_tracer [-h] --host HOST --user USER [--database DATABASE] [-a]
                    [-s] [-d DESTINATION | --display]
                    query [query ...]

positional arguments:
  query                 Path to a file containing a single sql statement.

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           MySQL server host
  --user USER           MySQL server user
  --database DATABASE   MySQL database name
  -a, --ask-password    Do not try to retrieve password from keyring, always
                        ask password
  -s, --store_password  Store password into keyring after connecting to the
                        database
  -d DESTINATION, --destination DESTINATION
                        Directory where to export results
  --display             Do not export results but display them to stdout

It exposes the class Query. The constructor needs a path to a file containing a single sql statement and instances exposes the method export which creates a timestamped copy of the original file, appended with an execution report and an export of the result in the csv format.

Development

You can install dependencies with pip install -r requirements.txt.

You can run tests with pytest but you need to set PYTHONPATH.

$ export PYTHONPATH=mysql_tracer
$ python3 -m pytest

Or you can setup a test run with your IDE without any particular configuration.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mysql_tracer-1.0.2.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

mysql_tracer-1.0.2-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page