Skip to main content

dj-raw-sql

Dependencies Version Downloads Downloads

dj-raw-sql is just a wrapper over the standard Django query

This demo shows how to get the record(s) from the database

Example:

def get_music_by_id(id: int):
    return "SELECT * FROM dj_app_music WHERE id = %s", (id,)
from django.db import models

# Our demo model
class Music(models.Model):
    name = models.CharField(max_length=150)
    create_at = models.DateTimeField(auto_now_add=True)
    update_at = models.DateTimeField(auto_now=True)
    is_delete = models.BooleanField(default=False)
from django.http import JsonResponse
from django.views import View

from my_app.queries import get_music_by_id

from dj_raw_sql import QueryExecutor


class MyView(View):
    def get(self, request, *args, **kwargs):
        music: tuple[tuple] = QueryExecutor.fetchone(get_music_by_id, id=1)
        return JsonResponse({"name": music[0][1]})

Benchmarks

Q: How were performance tests conducted?

A: tests/test_collection/ performance tests are located here. A dataset of 5000 elements was generated and loaded into the database. Then the query "SELECT * FROM dj_app_music LIMIT %s" was called, where the value of LIMIT changed from 10 to 5000 in each test.


Test results

Number of items fetchall to_ordereddict=True
10 0.00006 0.00011
100 0.00017 0.00025
1000 0.00138 0.00207
5000 0.00658 0.01052

Improve project

If you want to improve the project then create "Issues" . If you want to help with writing tests or typing, create a "pull request".

Metadata

Release files for dj-raw-sql 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dj-raw-sql 3.0.0
File Size Uploaded Provenance Actions
dj_raw_sql-3.0.0.tar.gz 4.8 kB Without provenance Details for dj_raw_sql-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dj-raw-sql 3.0.0
File Interpreter ABI Platform Actions
dj_raw_sql-3.0.0-py3-none-any.whl Python 3 none any Details for dj_raw_sql-3.0.0-py3-none-any.whl

Total release size: 9.7 kB

Release files / dj_raw_sql-3.0.0.tar.gz

Download URL dj_raw_sql-3.0.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3746d746223202bd9b8848b0d1f6ebb278643ba85440032fc3d9533ab2ae57ad
BLAKE2b-256 checksum
How to use checksums
b9120d05a0d79369eb36d7a19b7827dab8d91194748d4cb6674f1c63c50bd3ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.0 CPython/3.12.0 Linux/6.2.0-1018-azure

Release files / dj_raw_sql-3.0.0-py3-none-any.whl

Download URL dj_raw_sql-3.0.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59c06b5b63a790a190dd6e126212255b37bb3f12aa0ba6b594c0b838a1b19c8e
BLAKE2b-256 checksum
How to use checksums
2dd527a3c8025d15adfce72904c7c6e47876497aff43d2a9c096399ab1184839
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.0 CPython/3.12.0 Linux/6.2.0-1018-azure

Security for dj-raw-sql 3.0.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page