Skip to main content

SQL study aid for the command line built with Python

Project description

SQL-BUDDY

Sql-buddy is a study aid for SQL fundamentals that you can run on the terminal. You can think of it as the command-line version of index cards you would normally use for studying a subject.

Installation

You can install sql-buddy with pip:

pip install sql-buddy

sql-buddy is supported by Python 3.7 and above.

How to use

sql-buddy is a command line application. There are two components:

  1. The first component emulates a simple collection of object that represent SQL concepts like GROUP BY:

$ python -m sql_buddy

Welcome to sql-buddy. Populating In-memory Database...

Press Esc + ENTER to enter sql_buddy commands. Press CTRL-D to quit

Type 'commands' and press Esc + ENTER to get a list of sql_buddy commands

As the instructions state you can type 'commands' and hit Esc + ENTER (RETURN):

commands * list all: lists all the SQL concepts and queries * list some: list the first 10 concepts in the SQL concepts database * search=>{concept_name} gives you the definition, syntax, and usage of a specific SQL concept like group_by * i.e. search=>group_by * i.e. search=>order_by * i.e. search=>where * all SQL concept names must be in lowercase and have underscores in place of spaces

> list all

group_by:

Divide the rows returned from the select statement into groups. For each group, you can apply an aggregate function like sum(), min(), max(), avg().

group_by_with_having:

We use having in place of the where clause because aggregations like sum() do not work with the where clause.

To search the definition, syntax, usage, and related concepts of a specific SQL concept:

> search=>group_by

group_by:

Divide the rows returned from the select statement into groups. For each group, you can apply an aggregate function like sum(), min(), max(), avg().

syntax: select col_1, col_2 from table_name group by col_1, col2

usage: select staff_id, count(staff_id) from payment group by staff_id

related concepts: ['group_by_with_having', 'where', 'having', 'order by', 'aggregation', 'sum', 'min', 'max', 'avg']

The syntax for any individual SQL concept is:

> search=>{concept_name}

Like Python variables concept names cannot have spaces and must be lowercase.

  1. The second component is an SQL REPL straight from the prompt-toolkit documentation example tutorial:

prompt-toolkit

Run sql_buddy like before but with the -o flag:

$ python -m sql_buddy -o

And simply type SQLite queries:

select last_name, first_name, execution_date from deathrow limit 3;

('Brooks, Jr.', 'Charlie', '1982-12-07')

('Autry', 'James', '1984-03-14')

("O'Bryan", 'Ronald', '1984-03-31')

Sql-buddy comes with a csv data called tx_deathrow_full.csv that contains information about Texas deathrow inmates: selectstarsql.com.

The ideal setting for sql-buddy is two have two terminals open at the same time. One to utilize the first component to look up SQL concepts, and the other to run queries against an actual SQLite database table.

All data makes use of in-memory-only databases created through sqlite3 and sqlalchemy methods.

For help:

$ python -m sql_buddy -h

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

sql-buddy-1.0.4.tar.gz (115.6 kB view details)

Uploaded Source

Built Distribution

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

sql_buddy-1.0.4-py3-none-any.whl (116.1 kB view details)

Uploaded Python 3

File details

Details for the file sql-buddy-1.0.4.tar.gz.

File metadata

  • Download URL: sql-buddy-1.0.4.tar.gz
  • Upload date:
  • Size: 115.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for sql-buddy-1.0.4.tar.gz
Algorithm Hash digest
SHA256 894c7a36e4917fac2e9e3fd7798e51a0ea02a4df3037a16d9b18161dc8fe02c7
MD5 b3c5bdf7901887fbc48dd7ddf2789409
BLAKE2b-256 7afc1ec92625acd1a4937894266ed467a0c2f9b0bcdd4e4a55a27c7b90daf342

See more details on using hashes here.

File details

Details for the file sql_buddy-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: sql_buddy-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 116.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for sql_buddy-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3f30034bb8f2fc4956e8c99c99d65cce339ac33d380047b8dabae65f3b69dfd5
MD5 cf77f892b37f3a37eb9717bf857ac5bd
BLAKE2b-256 557f3ce39ecf0a2da659a1a0bae572e8dbb7acc98d5c38f2c3608af239e6414a

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