Skip to main content

Blocks any DB query from being executed within the context.

Project description

django-query-blocker

Prevents django to perform any query within the context or decorated method

Table of Contents

  1. Why Should I Use This?
  2. How To Install
  3. How To Use
    1. Context
    2. Decorator

Why Should I Use This?

Django ORM is great and easy to use but can easily hide some very back behaviours. Just by calling a property here and there you can cascade a chain of hundreds of queries hidden behind the easy-to-use model abstractions. This lib prevents it to happen by locking the ORM not allowing it to perform the queries by raising an exception.

How To Install

  • Install with
pip install django-query-blocker

How To Use

  • It can be used as a context or decorator

Context

from query_blocker import block_extra_queries

my_object = MyModel.objects.first()
print(my_object)  # works fine
with block_extra_queries:
    print(obj.foreign_key_obj) # will raise a NoExtraQueryException

Decorator

from query_blocker import block_extra_queries

@block_extra_queries
def my_method(obj):
    print(obj.foreign_key_obj)

my_object = MyModel.objects.first()
print(my_object)  # works fine
my_method(my_object)  # will raise a NoExtraQueryException

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

django-query-blocker-0.0.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_query_blocker-0.0.1-py2.py3-none-any.whl (3.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-query-blocker-0.0.1.tar.gz.

File metadata

  • Download URL: django-query-blocker-0.0.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for django-query-blocker-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c9f61a0db0d03f1d204833e41409c78f5422ea82fb87325a5638d08617f6f567
MD5 626161004f7302edcc30dcc4bf95e294
BLAKE2b-256 0638cb25f0ec11c78a055c9e6cca8f201b5b3ee020955d90299daf934a937b45

See more details on using hashes here.

File details

Details for the file django_query_blocker-0.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_query_blocker-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b12b44723876a7764ebc2439810ce40a2c516546ddfbd2fd270645d87e61dccc
MD5 b3962c9418173d6aeba1984083404086
BLAKE2b-256 9b7a7f1b0d5f67e0400d46180fcf215ccd935cb639e541a97aca90fccba1ebe2

See more details on using hashes here.

Supported by

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