querulous_quarrel
Named for a lovely groups of sparrows that happened to be flying by. A library that makes writing and executing queries a little easier for data scientists.
quarrel uses concentric and waddle and is proudly sponsored by the m&a
team at cscgh.
installation
cd /path/to/repo
pip install quarrel
quick start
-
create a config file
oracle: host: oracle.example.com user: scott password: tiger sid: xe -
initialize concentric with the config file from (1)
from concentric.managers import setup_concentric setup_concentric('/path/to/oracle.yml') -
(optional) initialize the sql template directories
from quarrel.settings import setup_quarrel setup_quarrel('/path/to/jinja2/sql/templates', '/path/to/jinja2/sql/queries') -
query the database
from quarrel.raw import query results = query('oracle', 'select sysdate from dual')
raw results -- get raw results from the dbapi connection
quarrel.raw allows you to get the tuples as they were returned by the
underlying dbapi connection. the header will be the cursor.description
returned from the query, and the results will be the list of tuples returned
by the query.
> from quarrel.raw import query
> header, results = query('oracle', 'select sysdate d from dual')
> print(header[0][0])
D
> print(results)
[(datetime.datetime(2022, 6, 26, 15, 10, 59),)]
cooked results -- get results as a list of dicts
quarrel.cooked allows you to get a list of dicts which is slightly easier to
understand and work with but can be substantially slower as python will
construct a dict per row that is returned. Each key of the dict will be
the lower-cased column name specified in the query.
> from quarrel.cooked import query
> results = query('oracle', 'select sysdate d from dual')
> print(results)
[{'d': datetime.datetime(2022, 6, 26, 15, 14, 12)}]
sqlalchemy results
quarrel.sqlalchemy allows you to get a list of dicts as well. However,
it uses sqlalchemy under the hood. This can be useful when you need sql alchemy's
connection pooling features.
> from quarrel.sqlalchemy import query
> results = query('oracle', 'select sysdate d from dual')
> print(results)
[{'d': datetime.datetime(2022, 6, 26, 15, 14, 12)}]
pandas results
quarrel.pandas allows you to get a dataframe using either the dbapi
connection or a sqlalchemy connection.
> from quarrel.pandas import query
> results = query('oracle', 'select sysdate d from dual')
> print(results)
d
0 2022-06-26 15:20:34
> from quarrel.pandas import query_alchemy
> results = query_alchemy('oracle', 'select sysdate d from dual')
> print(results)
d
0 2022-06-26 15:20:34
In order to use pandas, make sure you install pandas support using
the pandas extra
pip install quarrel[pandas]
Metadata
Release files for quarrel 0.6
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 |
|---|---|---|---|---|
| quarrel-0.6.tar.gz | 7.2 kB | Without provenance | Details for quarrel-0.6.tar.gz |
Release files / quarrel-0.6.tar.gz
| Download URL | quarrel-0.6.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df7a3930c24b118d5a970cb797b9baec29f3c869ae10fc7a1e3a98b6e08d3298
|
|
BLAKE2b-256 checksum How to use checksums |
79cc78629855ad36efecadfa0596d1f3b2c541f4686e3d52f819e94b7b856af8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.5
|
Security for quarrel 0.6
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.