Skip to content
Interactive SQL database exploration in Python
Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs/images
query
tests
.gitignore
.travis.yml
LICENSE.md
README.md
push_to_pypi.sh
requirements.txt
setup.py
test_requirements.txt

README.md

query

Python module for quick, interactive exploration of SQL databases. Designed especially for use with IPython. Light wrapper on top of Pandas (>= 0.16) and SQLAlchemy (>= 0.9.9). The most recent release is available on PyPI and can be installed via pip install query with the proper dependencies.

Build Status

Quickstart

from query import QueryDb
db = QueryDb(demo=True)

But the real joy comes when using query interactively:

Interactive query use demo #1

Key functionality

A few key functions to remember:

  • db: The main database object. Print it in IPython to see a list of tables and their key attributes.
  • db.inspect.*: Tab-completion across the database's tables and columns. Print any table to see its columns and their types.
  • db.query(): Query the database with a raw SQL query. Returns a pandas DataFrame object by default, but can return a sqlalchemy result object if called with return_as="result".

Roadmap

Further improvements are planned, including some of the below. Please feel free to open an Issue with desired features or submit a pull request.

  • Plotting: Graphical display of queried data (some of this can easily be done off the current DataFrame object, but it could be better integrated)
  • More Convenience Methods: Additional convenience methods, like .tail() and .where()
  • DB Schemas: Direct output of database schema diagrams
  • Password Input via IPython: Currently entering a DB password uses getpass in the user's terminal. Being able to enter the password directly into IPython would be ideal (while also not writing it into any history)
  • More/Better Documentation: Enough said.
You can’t perform that action at this time.