
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
django_print_sql is an easy-to-use SQL debug tool for Django developers to print SQL statements
django-print-sql is an easy-to-use SQL debug tool for Django developers to print SQL statements
2018.3.6
You need to have django installed (obviously).
I've tried it on Django 1.11.11 and 2.0.3.
If sqlparse is installed, the SQL statement wil be formatted.
From pip, run::
$ pip install --upgrade django-print-sql
Consider using the --user
option_.
.. _option: https://pip.pypa.io/en/latest/user_guide/#user-installs
From the repository, run::
python setup.py install
to install django-print-sql on your system.
django-print-sql is compatible with Python 2.7 and Python 3 (>= 3.3) (hopefully :D).
Install sqlparse to pretty print the statements::
$ pip install --upgrade sqlparse
Example 1. Use as context manager::
from django_print_sql import print_sql
count_only
to True
will print the number of executed SQL statements onlywith print_sql(count_only=False):
# write the code you want to analyze in here,
# e.g. some complex foreign key lookup,
# or analyzing a DRF serializer's performance
for user in User.objects.all()[:10]:
user.groups.first()
Example 2. Use as decorator::
from django_print_sql import print_sql_decorator
@print_sql_decorator(count_only=False) # this works on class-based views as well
def get(request):
# your view code here
Project Page https://github.com/rabbit-aaron/django-print-sql
django-print-sql is licensed under the MIT license.
Parts of the readme are based on sqlparse's readme file. sqlparse: https://github.com/andialbrecht/sqlparse
FAQs
django_print_sql is an easy-to-use SQL debug tool for Django developers to print SQL statements
We found that django-print-sql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.