preprocesses SQL queries to make them modular
Project description
# querypp
[![Build Status](https://img.shields.io/travis/bmintz/querypp/master.svg?label=tests)](https://travis-ci.org/bmintz/querypp) [![Coverage Status](https://coveralls.io/repos/github/bmintz/querypp/badge.svg?branch=master)](https://coveralls.io/github/bmintz/querypp?branch=master)
querypp preprocesses SQL queries[1] in order to “parameterize” them. It also includes a loader which loads many queries from a file, delimited by – :name query_name lines.
- [1] Although it is trivially adapted to other languages with line comments,
as the only SQL-specific assumption is the comment syntax.
Take an example:
` SELECT * FROM users -- :param profiles LEFT JOIN profiles USING (user_id) -- :param login_history LEFT JOIN login_history USING (profile_id) -- :endparam -- :endparam -- :param user_id WHERE user_id = $1 `
- A Query object can be called:
with no parameters to return the entire query
with one or more parameters to return the query with only those parameters.
In this case, q(‘profiles’, ‘user_id’) would return the query with the login_history JOIN removed.
## Motivation
After moving all my SQL queries to separate files (using the load_sql function), I noticed that some of them were being duplicated except for one extra clause. I created this to allow me to deduplicate such queries.
## License
Public domain, see [COPYING](/COPYING)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for querypp-0.0.1.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e0772680e183a1e2b815033a8ad4dcf1f6950adce7c09c98f60107dd40eff8b |
|
MD5 | 32e735191d750e6d66aef56eeddef2ea |
|
BLAKE2b-256 | 79d527cedc161703c86a410726954a2bf72320c94317bca0b6bf0f1857f35b76 |