Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A Python package to create simple SQL queries from the console, and quickly display the returned information.

Project Description

Helper to consume a database from the REPL.


  • pypyodbc
  • tabulate
  • Configuration file database.ini. A template is included in the source.

Full documentation available in


>>> from pyquebec import pyquebec
>>> from pyquebec import formatters as pf
>>> pyquebec.add('SampleDB', 'connection string here', 'MSSQL') # first use
>>> db ='SampleDB') # after using add, the db config and schema is cached
>>> db.dbo.<TAB KEY>
db.dbo.Table1  db.dbo.Table2
db.dbo.Table3  db.dbo.Table4
>>>result = db.dbo.Table1.From().go()
>>> pf.to_html(result)
Creating and opening temp file C:\Users\smonia\AppData\Local\Temp\tmpn3g43ppp.htm
>>> pf.to_csv(result)
Creating and opening temp file C:\Users\smonia\AppData\Local\Temp\tmpe68shxd9.csv
>>> result[0]
row(column1=datetime.datetime(2015, 5, 13, 23, 34, 58, 77000), column2=59, column3=29, column4='Sample')

Pypyodbc returns tuples. This library converts them to namedtuples for increased readability and to make it easier to keep playing with the data using filter, map, sorted, etc.

There’s a third option in the formatters that uses tabulate for output to_console(). Both HTML and CSV options create a temp file and use os.startfile (in Windows you get the default browser and, usually, Excel).

Roadmap (help/guidance appreciated!):

  • Tested with MSSQL and SQLite. With some configuration should support other engines, and ideally the config should be included in the package.
  • The API for querying might need a few tweaks. Suggestions are welcome.
  • Decide on other SQL features to support beyond basic querying. UPDATES, INSERTS, GROUP BY, etc, would it make sense? Would this make supporting other products more difficult?
  • Needs more unittest!

Contributors: Sebastián Monía - Fernando Antivero -

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pyquebec-0.9.0-py3-none-any.whl (76.2 kB) Copy SHA256 Checksum SHA256 3.4 Wheel Dec 9, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting