Skip to main content

SQL query interface for NetBox with syntax highlighting, abstract views, and role-based access control

Project description

netbox-sqlquery

CI License

A NetBox plugin that provides a SQL query interface with syntax highlighting, abstract views, saved queries, and role-based access control.

Features

  • SQL console with real-time syntax highlighting and auto-uppercase keywords
  • Abstract views (nb_*) that resolve foreign keys to names and aggregate tags
  • Schema sidebar with search filter and Raw SQL / Views toggle
  • Interactive results: click columns to refine SELECT, click cells to add WHERE filters
  • Saved queries with save/load dialogs and private/public visibility
  • Write query support (INSERT, UPDATE, DELETE) with confirmation dialog
  • Role-based access control integrated with NetBox's ObjectPermission system
  • Per-user color preferences for syntax highlighting
  • CSV export
  • Compatible with NetBox 4.6.x, netbox-docker, and OIDC providers (NetBox 4.5.x: use plugin 0.1.x)

Screenshots

Views mode

Query abstract views that resolve foreign keys and aggregate tags, matching how data appears in the NetBox UI.

Views mode query

Raw SQL mode

Query the database directly with full PostgreSQL power.

Raw SQL query

Column select

Click column headers to refine which columns are returned.

Column selection

Saving queries

Save queries for reuse with private or public visibility.

Save query dialog

Saved queries list

Saved queries list

Permissions setup

Control access using NetBox's native ObjectPermission system.

Permissions setup

User preferences

Customize syntax highlighting colors per user.

User preferences

Compatibility

See COMPATIBILITY.md for the full version matrix.

NetBox version Python versions
4.6.x 3.12, 3.13, 3.14

Installation

cd /path/to/netbox
venv/bin/pip install netbox-sqlquery

Add to your NetBox configuration.py:

PLUGINS = ["netbox_sqlquery"]

PLUGINS_CONFIG = {
    "netbox_sqlquery": {
        "require_superuser": True,
        "max_rows": 1000,
        "statement_timeout_ms": 10000,
        "deny_tables": [
            "auth_user",
            "users_token",
            "users_userconfig",
        ],
    }
}

Run migrations:

cd /path/to/netbox
venv/bin/python netbox/manage.py migrate netbox_sqlquery

Collect static files:

venv/bin/python netbox/manage.py collectstatic --no-input

For Docker-based installations, see docs/docker.md.

Configuration

Setting Type Default Description
require_superuser bool True Require superuser to access the query view
max_rows int 1000 Maximum rows returned per query
statement_timeout_ms int 10000 PostgreSQL statement timeout in milliseconds
deny_tables list ["auth_user", "users_token", "users_userconfig"] Tables blocked for all users including superusers
top_level_menu bool False Show as a top-level nav menu instead of under Plugins

Documentation

License

Apache 2.0. See LICENSE.

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

netbox_sqlquery-0.2.0.tar.gz (56.8 kB view details)

Uploaded Source

Built Distribution

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

netbox_sqlquery-0.2.0-py3-none-any.whl (67.9 kB view details)

Uploaded Python 3

File details

Details for the file netbox_sqlquery-0.2.0.tar.gz.

File metadata

  • Download URL: netbox_sqlquery-0.2.0.tar.gz
  • Upload date:
  • Size: 56.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for netbox_sqlquery-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c56b344aecec77c0f3ce0ee27902edf40f060243b7e17a7a3c77e12c3f326245
MD5 88b55e03636b12e7075be7c0f958ce3c
BLAKE2b-256 bf6bb43cf6972e660cab0254d65063477d940383dfe37bf3e4e4b7c0af024ebf

See more details on using hashes here.

Provenance

The following attestation bundles were made for netbox_sqlquery-0.2.0.tar.gz:

Publisher: publish.yml on ravinald/netbox-sqlquery

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file netbox_sqlquery-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for netbox_sqlquery-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 221f42a8e8bbd45f784092a4efd03457b6f72ff2c640b7046f01b160a3f1fed0
MD5 d50a2a7e316e6ecf156001c7ff99d907
BLAKE2b-256 094b042a65f8e2d0acd307f4399cdd5bc5e41b736f8fd71edb31f3d8e9bf154e

See more details on using hashes here.

Provenance

The following attestation bundles were made for netbox_sqlquery-0.2.0-py3-none-any.whl:

Publisher: publish.yml on ravinald/netbox-sqlquery

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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