Skip to content

A Django middleware package that helps inspect and trace SQL query executions in your terminal.

Notifications You must be signed in to change notification settings

xasterKies/dg-sqltrace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚙️ dg-sqltrace

A Django middleware package that helps inspect and trace SQL query executions in your terminal. - Used to easily debug a bunch of intertwined SQL queries in your terminal.

most language stars Contributors

Alt text

Why?

I started developing this tool in response to a challenge I encountered while working on a pre-existing Django application. Upon joining the project, I discovered the project had numerous bugs in its SQL queries, and its logic was convoluted, which made debugging quite a difficult task. I had to map out all the SQL relationships by hand to be able to move on with the application development irrespective of its intertwined SQL logic. During that period, I longed for a solution that would systematically trace and examine every executed SQL query within the application in an orderly manner for the purpose of debugging. That's why I embarked on building this tool.

Features

  • Trace SQL queries
  • Inspect and check traces of repeated SQL queries

Dependencies and Installs

Install package in an existing Django application

  1. Pip install dg-sqltrace in your application directory

    pip install dg-sqltrace
  2. Navigate to your settings.py file and at the top add this line:

    from dg-sqltrace import middleware
  3. Next move down in your settings.py file to your MIDDLEWARE array and add middleware to one of the array elements like this:

    ... ,
    ... ,
    middleware
  4. Re-run your server

  5. Check your terminal and you should be good to go to inspect all executed SQL queries in your application.

Setting up the project for contributions and experimentation.

  1. Fork repository

  2. Clone the forked repository in prefered directory

    git clone <project-url>
  3. Enter project directory

    cd dg-sqltrace
  4. Create a virtual enviroment

    python3 -m venv env
  5. Activate virtual environment

    source env/bin/activate
  6. Install dependencies

    pip install -r requirements.txt
  7. Run

    python3 manage.py runserver
  8. Visit localhost:8000/

    This step automatically populate an SQLite database, query and inspect 1 query by default in your terminal.

Contributing

if you will like to make a contribution or suggest anything to the project, will be happy to hear from you in issues or PRs section :)

About

A Django middleware package that helps inspect and trace SQL query executions in your terminal.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages