Get Started

Garrick Aden-Buie

2017-07-12

🐿 sqrrl

sqrrl is a small collection of utility functions that help build text-based SQL queries in an R-style native-feeling and functional manner.

Unlike other packages that build SQL queries using an object-oriented style, sqrrl provides small functions that produce SQL snippets and can be linked together to compose SQL queries. The result is that the code to produce the SQL statement reads much like the SQL statement iteself. On the other hand, sqrrl doesn’t know anything about your database and can’t help you out with completions, etc.

Complete Example

SELECT mpg, wt AS weight, cyl AS cylinders FROM mtcars WHERE gear<4 AND mpg>=15 AND cyl IN (4, 6)

Formatting SQL Queries

sqrrl also provides a simple wrapper for https://github.com/andialbrecht/sqlparse, a Python package for formatting SQL queries. sqlparse can be installed via pip install --upgrade sqlparse, thereafter making available the system command sqlformat.