All Projects → paul-wolf → djaq

paul-wolf / djaq

Licence: MIT license
Django queries

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to djaq

django-sqlalchemy
Django ORM built on top of SQLalchemy core 2.0 for seamless integration of SQLAlchemy with Django 4.1+ PostgreSQL 14+ only for now. [pre POC now]
Stars: ✭ 101 (+87.04%)
Mutual labels:  django-orm, django-models
django-slugs-example-app
A basic app to show how to add slugs to models
Stars: ✭ 12 (-77.78%)
Mutual labels:  django-application
Django Crud Ajax Login Register Fileupload
Django Crud, Django Crud Application, Django ajax CRUD,Django Boilerplate application, Django Register, Django Login,Django fileupload, CRUD, Bootstrap, AJAX, sample App
Stars: ✭ 118 (+118.52%)
Mutual labels:  django-application
College Erp
A college management system built using Django framework. It is designed for interactions between students and teachers. Features include attendance, marks and time table.
Stars: ✭ 187 (+246.3%)
Mutual labels:  django-application
Hsreplay.net
🔶 Unleash your Potential!
Stars: ✭ 132 (+144.44%)
Mutual labels:  django-application
Django Rest Registration
User-related REST API based on the awesome Django REST Framework
Stars: ✭ 240 (+344.44%)
Mutual labels:  django-application
Banking System
A banking System Created Using Django Python Web Framework
Stars: ✭ 105 (+94.44%)
Mutual labels:  django-application
Judge-Jury-and-Executable
A file system forensics analysis scanner and threat hunting tool. Scans file systems at the MFT and OS level and stores data in SQL, SQLite or CSV. Threats and data can be probed harnessing the power and syntax of SQL.
Stars: ✭ 66 (+22.22%)
Mutual labels:  query-language
OLD-vital-development
No description or website provided.
Stars: ✭ 18 (-66.67%)
Mutual labels:  django-application
Niji
A pluggable Django forum APP
Stars: ✭ 173 (+220.37%)
Mutual labels:  django-application
Django Settings Export
Access Django settings from templates the right way™
Stars: ✭ 167 (+209.26%)
Mutual labels:  django-application
Django Dersleri
YouTube Django Dersleri için proje kaynak kodu
Stars: ✭ 135 (+150%)
Mutual labels:  django-application
django-shortcodes
A Django application to parse WordPress shortcodes.
Stars: ✭ 13 (-75.93%)
Mutual labels:  django-application
Django Lockdown
Lock down a Django site or individual views, with configurable preview authorization
Stars: ✭ 123 (+127.78%)
Mutual labels:  django-application
transtats
Track translations and automate workflow.
Stars: ✭ 31 (-42.59%)
Mutual labels:  django-application
Django Pattern Library
UI pattern libraries for Django templates
Stars: ✭ 110 (+103.7%)
Mutual labels:  django-application
Patchman
Patchman is a Linux Patch Status Monitoring System
Stars: ✭ 163 (+201.85%)
Mutual labels:  django-application
Alfanous
Alfanous is an Arabic search engine API provides the simple and advanced search in Quran , more features and many interfaces...
Stars: ✭ 209 (+287.04%)
Mutual labels:  django-application
Django-WebApp
This is a web-app created using Python, Django. By using this user can login, upload files and also can view and download files uploaded by other users.
Stars: ✭ 285 (+427.78%)
Mutual labels:  django-application
planb
PlanB - automating remote backups and snapshots with zfs/rsync
Stars: ✭ 24 (-55.56%)
Mutual labels:  django-application

Djaq

Unit test status Documentation Status PyPI - Python Version PyPi Version

Djaq - pronounced “Jack” - is an alternative to the Django QuerySet API.

What sets it apart:

  • No need to import models
  • Clearer, more natural query syntax
  • More powerful expressions
  • More consistent query syntax without resorting to idiosyncratic methods like F() expressions, annotate(), aggregate()
  • Column expressions are entirely evaluated in the database
  • Extensible: you can write your own functions
  • Pandas: Easily turn a query into Pandas Dataframe

There is also a JSON representation of queries, so you can send queries from a client. It's an instant API to your data. No need to write backend classes and serializers.

Djaq queries are strings. A query string for our example dataset might look like this:

DQ("Book", "name as title, publisher.name as publisher").go()

This retrieves a list of book titles with book publisher. But you can formulate far more sophisticated queries; see below. You can send Djaq queries from any language, Java, Javascript, golang, etc. to a Django application and get results as JSON. In contrast to REST frameworks, like TastyPie or Django Rest Framework (DRF), you have natural access to the Django ORM from the client.

Djaq sits on top of the Django ORM. It can happily be used alongside QuerySets.

Here's an example comparison between Djaq and Django QuerySets that gets every publisher and counts the books for each that are above and below a rating threshold.

DQ("Book", """publisher.name,
    sumif(rating < 3, 1, 0) as below_3,
    sumif(rating >= 3, 1, 0) as above_3
    """)

compared to QuerySet:

from django.db.models import Count, Q
above_3 = Count('book', filter=Q(book__rating__gt=3))
below_3 = Count('book', filter=Q(book__rating__lte=3))
Publisher.objects.annotate(below_3=below_3).annotate(above_3=above_3)

Get average, maximum, minimum price of books:

DQ("Book", "avg(price), max(price), min(price)")

compared to QuerySet:

Book.objects.aggregate(Avg('price'), Max('price'), Min('price'))

Get the difference from the average off the maximum price for each publisher:

DQ("Book", "publisher.name, max(price) - avg(price) as price_diff")

compared to QuerySet:

from django.db.models import Avg, Max
Book.objects.values("publisher__name") \
   .annotate(price_diff=Max('price') - Avg('price'))
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].