Skip to main content

Organize app queries in an annotated SQL file.

Project description

https://travis-ci.org/solidsnack/query-selector.svg?branch=master

Query selector allows one treat a file full of SQL queries as a record, with one attribute for each annotated query. This makes working with long, ad-hoc SQL queries more hygienic, and has the benefit of making it easy to find the queries.

The QuerySelector constructor accepts a string, file handle or (<package>, <resource) pair and parses the SQL into groups annotated with --@ <name> <mode>. The <name> is any Python compatible name; it will become an attribute of the object. The <mode> is merely metadata, and can be omitted; it describes whether a query should have one, none or many results.

For example, a file like this:

--@ t one
SELECT * FROM now();

becomes an object with a single attribute t:

>>> q.t
Query(args=[], mode=u'one', text=u'SELECT * FROM now();')

Project details


Download files

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

Source Distribution

query-selector-0.99.0.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file query-selector-0.99.0.tar.gz.

File metadata

File hashes

Hashes for query-selector-0.99.0.tar.gz
Algorithm Hash digest
SHA256 11a3b1ee9ba3a2c0eccc8f647e4ea162ead73c43f420e267b894acda4d16d74c
MD5 709ed939270b9608ea4a206b1d317383
BLAKE2b-256 8a90347a7f836579b02e44347a17df793cbf60a97340f1bc6b5a33aa5615a699

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page