Skip to main content

Convert SQL to most human readable format

Project description

readsql

Convert SQL to most human readable format

Installation

pip install readsql

Usage

  • Format SQL code provided in command line
    • readsql <SQL_STRING> -s
    • e.g., readsql 'select sushi from tokyo' -s
    • prints out SELECT sushi FROM tokyo
  • Format an SQL file
    • readsql <FILE_PATH>
    • e.g., readsql sql_example.sql
    • given a Python file (ends with .py), it looks for variables query and formats their insides
    • variable to represent SQL code can be change with -py option
    • e.g., readsql sql_in_python_variable_example.py -py sql
    • given a Python file with this code
def get_query():
    limit = 6
    sql = f"SELEct speed from world where animal='dolphin' limit {limit}"
    return sql

converts it to

def get_query():
    limit = 6
    sql = f"SELECT speed FROM world WHERE animal='dolphin' LIMIT {limit}"
    return sql

Development

Having the repo cloned

  • python readsql tests/sql_example.sql converts example SQL code to easier readable format
  • python readsql tests/sql_in_python_example.py converts example SQL code in Python (it looks for variables query)
  • we can change the SQL variable with -py option python readsql tests/sql_in_python_variable_example.py -py sql
  • python readsql "select gold from mine" -s takes the "select gold from mine" string as input and outputs it formatted

Testing

Have pytest installed and run pytest -v (-v stands for verbose)

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

readsql-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

readsql-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file readsql-0.1.0.tar.gz.

File metadata

  • Download URL: readsql-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.7.7 Darwin/18.7.0

File hashes

Hashes for readsql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1769a79104502c31bbbe356be61571ae212b37fc68baa05159fa2466e519a27f
MD5 84b132c3164ec3d6e61ec6d947473fe5
BLAKE2b-256 48b33b9cddc1934560ed227434d6c3693e187af6bd3089c97ee6a46d04120eed

See more details on using hashes here.

File details

Details for the file readsql-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: readsql-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.7.7 Darwin/18.7.0

File hashes

Hashes for readsql-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db118afd713e638dc2c92b473c9b35aafe014c15e4e1355f20e95ae04a957f0b
MD5 de0d2c7c4c4fd272c4b3fbd79fb9e513
BLAKE2b-256 c85f1753167eecc28b8aae7ab715d5210a4d44c30dca6b5fa35a26dd0c0e50b9

See more details on using hashes here.

Supported by

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