Registry / web-framework / django-sql-explorer

django-sql-explorer

JSON →
library5.3pypypi✓ verified 88d ago

Django SQL Explorer provides a delightful SQL editor and interface for writing and sharing SQL queries directly within a Django admin-like environment. It allows users to quickly generate reports, download data, and visualize results, with recent versions (like 5.3) adding AI assistance for query generation. It is actively maintained, with new releases often coinciding with major Django version compatibility updates.

pip install django-sql-explorer
INSTALL
IMPORT
SIG · DJANGO-SQL-EXPLORE
D
django-sql-explorer
web-frameworkpythonv5.3
Install
5.2s avg
Import
—
Disk
89MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v5.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 89.7MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 5.2s · import 0.000s · 90MB
89MB installed
● package 89MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_version
✓ from explorer import get_version
✗ import explorer

To set up Django SQL Explorer, first ensure you have Django installed. Then, install `django-sql-explorer` via pip. Add `'explorer'` to your `INSTALLED_APPS` in `settings.py` and include `explorer.urls` in your project's `urls.py`. Run `python manage.py migrate` to create Explorer's database tables. Access is typically restricted to staff or superusers by default. Navigate to `/explorer/` after running the development server and log in with an appropriate user.

import os # settings.py # Minimum settings for django-sql-explorer DEBUG = True SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'a-very-secret-key-for-dev') INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'explorer', # Add explorer app ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'myproject.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'myproject.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(os.getcwd(), 'db.sqlite3'), } } AUTH_PASSWORD_VALIDATORS = [ {'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'}, {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}, {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'}, ] LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True STATIC_URL = '/static/' # explorer specific settings (optional, defaults to is_staff checks) EXPLORER_PERMISSION_VIEW = lambda request: request.user.is_staff EXPLORER_PERMISSION_CHANGE = lambda request: request.user.is_superuser # myproject/urls.py # from django.contrib import admin # from django.urls import include, path # # urlpatterns = [ # path('admin/', admin.site.urls), # path('explorer/', include('explorer.urls')), # Add explorer URLs # ] # To run: # 1. pip install django django-sql-explorer # 2. Create a Django project and app (e.g., 'myproject') # 3. Replace myproject/settings.py and myproject/urls.py with the relevant parts above # 4. python manage.py migrate # 5. python manage.py createsuperuser # 6. python manage.py runserver # 7. Navigate to http://127.0.0.1:8000/explorer/ and log in with your superuser account.
Debug
Known issues
breakingMajor Django version compatibility: Ensure your `django-sql-explorer` version is compatible with your Django version. For example, older versions of explorer might not work correctly with Django 3.x, 4.x, or 5.x. Check the project's `setup.py` or documentation for `requires_django`.
fix
Upgrade `django-sql-explorer` to the latest version (`pip install --upgrade django-sql-explorer`) to ensure compatibility with recent Django releases. If specific compatibility is needed, consult the release notes.
affects: < 3.0 (Django 2.x), < 4.0 (Django 3.x)
gotchaSecurity Risk: Granting SQL access is powerful. Ensure `EXPLORER_PERMISSION_VIEW` and `EXPLORER_PERMISSION_CHANGE` settings are configured carefully. By default, these check `request.user.is_staff` and `request.user.is_superuser` respectively, but can be customized to any callable that returns True/False.
fix
Explicitly define `EXPLORER_PERMISSION_VIEW` and `EXPLORER_PERMISSION_CHANGE` in `settings.py` to match your organization's security policies. For example, `EXPLORER_PERMISSION_VIEW = lambda request: request.user.groups.filter(name='Data Analysts').exists()`.
affects: All versions
gotchaDatabase Connections: `django-sql-explorer` uses your Django project's default database connection. If you have multiple databases configured, you need to be mindful of which database it's querying. It does not natively support switching between multiple configured databases within the explorer UI, though custom solutions or proxy views could achieve this.
fix
If querying a specific non-default database is required, consider configuring that database as the 'default' for a separate explorer instance, or use Django's database routing feature to direct `explorer`'s queries to a specific database if you have custom logic.
affects: All versions
deprecatedOld URL patterns: In very old versions (<3.0), the URL inclusion pattern or some view names might have been different, leading to `NoReverseMatch` errors.
fix
Ensure you are using `path('explorer/', include('explorer.urls'))` in your project's `urls.py`. Always refer to the official documentation for the version you are using for the correct URL configuration.
affects: < 3.0
Upgrade
Version history
5.3latest on PyPI · released Sep 24, 2024
Audit
Dependencies
Djangorequireddjango-sql-explorer is a Django application and requires a Django project to run.
Agent activity
12 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
django-sql-explorer — pip install django-sql-explorer · libregistry