querypp
Deprecation Notice
querypp has been deprecated in favor of vanilla jinja2. After porting it to jinja2, I realized that none of querypp was actually necessary. Migrating docs here.
v0.0.3 is the last version that doesn't use jinja2, in case you want a more lightweight version.
querypp is a SQL query[1] templating system based on jinja2.
[1]: Although it is trivially adapted to other languages, as the only SQL-specific assumption is the line comment syntax.
Take an example:
-- :query users
SELECT *
FROM users
-- :qblock profiles
LEFT JOIN profiles USING (user_id)
-- :block login_history
LEFT JOIN login_history USING (profile_id)
-- :endqblock
-- :endqblock
-- :qblock user_id WHERE user_id = $1
-- :endquery
A Query template can be called:
- with no block names to return the query without any blocks
- with one or more block names to return the query with only those block names.
In this case, q('profiles', 'user_id') would return the query with the login_history JOIN removed.
Additionally, any jinja2 templating features,
such as variables and macro functions, can be used, using either the line syntax (e.g. -- :include 'foo.sql')
or the block syntax (e.g. {% if x == 1 %}).
Usage
env = querypp.QueryEnvironment('sql/')
queries = env.get_template('queries.sql') # opens sql/queries.sql
db.execute(queries.users('login_history', 'user_id'), user_id)
Motivation
After moving all my SQL queries to separate files, I noticed that I was duplicating some of them except for one extra clause. I created this to allow me to deduplicate such queries.
License
Public domain, see COPYING
Metadata
Release files for querypp 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| querypp-0.1.2.tar.gz | 3.5 kB | Without provenance | Details for querypp-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| querypp-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for querypp-0.1.2-py3-none-any.whl |
Total release size: 9.8 kB
Release files / querypp-0.1.2.tar.gz
| Download URL | querypp-0.1.2.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12e1d42e7a5616b9dd94fe2a8f0375c05d32c6b8dfa86fa935b6990b37984832
|
|
BLAKE2b-256 checksum How to use checksums |
04b027f30f3a8b774ff6c0dbbb8374ff41c2cd339f0f143762edf9422a71831b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
|
Release files / querypp-0.1.2-py3-none-any.whl
| Download URL | querypp-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2135587be928aa57a54244fcc354559f48b8f281fd6a33699a3e3b2286e5e11
|
|
BLAKE2b-256 checksum How to use checksums |
823e437d5dd925675ff6f8ea88d7b2d48fb86abf2a5377a4609dd598e1730da5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
|
Security for querypp 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.