Records¶
Records is a deceptively simple but powerful library for making raw SQL queries to most relational databases. Powered by SQLAlchemy and Tablib, it covers many database types and allows you to export your results to CSV, XLS, JSON, HTML Tables, YAML, or pandas dataframes with a single line of code.
Install
pip install --upgrade records sqlalchemy-cratedb
Synopsis
import records
db = records.Database("crate://", echo=True)
rows = db.query("SELECT region, mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3")
data = rows.all()
print(rows.export("json"))
See also
Documentation
The full documentation for Records.
Example
An executable example using Records as a library.
Example
An executable example using Records as a CLI.