Copyright (c) 2009-2014 Dennis Kaarsemaker <dennis@kaarsemaker.net> A command-line interface to query the Django ORM
- Install:
python setup.py install
Add cli_query to the INSTALLED_APPLICATIONS setting in your settings.py
Usage: cd your_project_dir; ./manage.py query [options] [filters]
The django ORM will be queried with the filters on the commandline. Records will be separated with newlines, fields with the specified separator (the default is a comma). Alternatively, a template can be specified which will be passed the result of the query as the ‘objects’ variable
Query key/value pairs can be prefixed with a ‘!’ or ‘~’ to negate the query. The __in filter works, use a comma separated string of arguments
You can also update fields using -u field=value. For every changed object, you will be prompted to approve the changes.
- Examples:
Display name and assettag of all mc01 servers %prog query -a servers -m Server name__startswith=mc01 -f name,assettag
Get a list of name, ip, mac for all servers where the does not contain .82. %prog query -a servers -m Interface !ip_address__contains=’.82.’ -f server.name,ip_address,mac_address
Use a template to get the roles, depending on mac address %prog query -a servers -m Server interface__mac_address=00:17:A4:8D:E6:BC -t ‘{{ objects.0.role_set.all|join:”,” }}’
List all eth0/eth1 network interfaces %prog query -a servers -m Interface name__in=eth0,eth1 -f ip_address,mac_address
Update the state of all mc2* servers $prog query -a servers -m Server name__startswith=mc2 -u status=live
Operators you can filter with are listed on https://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups
Metadata
Release files for django-cli-query 1.3
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 |
|---|---|---|---|---|
| django-cli-query-1.3.tar.gz | 4.8 kB | Without provenance | Details for django-cli-query-1.3.tar.gz |
Release files / django-cli-query-1.3.tar.gz
| Download URL | django-cli-query-1.3.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c949915c66baabb21c1c58639e62abc16e33ced10d09da20680c3f496469d54
|
|
BLAKE2b-256 checksum How to use checksums |
7c55015d3cf9cba65e3d81e7f6f9a803f6c1029479e4d7b4d93a19fee986b713
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-cli-query 1.3
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.