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.
from query import QueryDb db = QueryDb(demo=True)
But the real joy comes when using query interactively:
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 DataFrameobject by default, but can return a
sqlalchemy resultobject if called with
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
DataFrameobject, but it could be better integrated)
- More Convenience Methods: Additional convenience methods, like
- DB Schemas: Direct output of database schema diagrams
- Password Input via IPython: Currently entering a DB password uses
getpassin 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.