Skip to main content

dbreak

A development database debugging tool that lets you set breakpoints and issue direct queries to one or more databases. Extensible via plugins to allow you to query a wide range of database types, both SQL and NoSQL.

Requires Python 3.6+

Installation

Install from PyPi using pip:

pip install dbreak

The base dbreak package includes support for DB API-compliant connections, such as the following:

  • sqlite3 (built-in)
  • psycopg2
  • pymysql

Add support for additional connection types by installing plugins:

Usage

Your main interaction will be with the show_console() function. This pauses the application and lets you query any database connections you've provided.

Basic Usage

Example using a SQLite in-memory database:

import sqlite3
import dbreak

# Set up a SQLite connection as you normally would
connection = sqlite3.connect(":memory:")

# Add a table
connection.execute("create table foobar(x int, y int)")

# Add a row
connection.execute("insert into foobar select 1, 2")

# Pause execution and enter the console
dbreak.start_console(connection)

Once the start_console command is encountered you'll enter an interactive console where you can query the database using the connections you've provided:

Starting debug session on connection 'db[0]'.
You may issue database commands by simply typing them and pressing enter.

Use !help for a list of special commands.
Use !exit to quit the debugger and resume the application.

db[0]> select * from foobar

===  ===
  x    y
===  ===
  1    2
===  ===
(1 row(s) returned)

Multiple Connections

If you have multiple database connections, you can name them via arguments to the show_console() command for easier access in the shell. Connections can be of the same type or different (for example, one shell could handle connections to both MySQL and Redis databases).

Example using two SQLite connections:

import sqlite3
import dbreak

# Set up a couple of SQLite connections
connection1 = sqlite3.connect(":memory:")
connection2 = sqlite3.connect(":memory:")

# Pause execution and enter the console
dbreak.start_console(
    conn1=connection1,
    conn2=connection2,
    starting_connection="conn1"
)

The starting_connection parameter takes a string that indicates what connection the shell should use initially. The other parameters act as names for the connections and can be anything you want.

Once inside the shell you can then use special commands (described via !help) to list and switch between the connections:

Starting debug session on connection 'conn1'.
You may issue database commands by simply typing them and pressing enter.

Use !help for a list of special commands.
Use !exit to quit the debugger and resume the application.

conn1> !connections

=================  ==============  =======================  ======================
Connection Name    Wrapper Type    Raw Connection Module    Raw Connection Class
=================  ==============  =======================  ======================
conn1              DBAPIWrapper    sqlite3                  Connection
conn2              DBAPIWrapper    sqlite3                  Connection
=================  ==============  =======================  ======================
(2 row(s) returned)

conn1> !switch conn2
conn2> 

Note that the name of the current connection is shown at the input prompt.

Metadata

Release files for dbreak 0.0.1

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

Source distribution (sdist)

Source distribution for dbreak 0.0.1
File Size Uploaded Provenance Actions
dbreak-0.0.1.tar.gz 12.3 kB Without provenance Details for dbreak-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dbreak 0.0.1
File Interpreter ABI Platform Actions
dbreak-0.0.1-py3-none-any.whl Python 3 none any Details for dbreak-0.0.1-py3-none-any.whl

Total release size: 27.3 kB

Release files / dbreak-0.0.1.tar.gz

Download URL dbreak-0.0.1.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c94505c8f659a3d5a5be2a9f6347db16c2bc4c10d39901088c4b422b8d54d330
BLAKE2b-256 checksum
How to use checksums
35ab7e9810e6b0c943fe18ae47f2a65e4fc9e04e9f9118dcdec5384056b36290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

Release files / dbreak-0.0.1-py3-none-any.whl

Download URL dbreak-0.0.1-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
562b228329f720fa8419315a7b9cc3c66309451a239a3bced651f7ca68e8364b
BLAKE2b-256 checksum
How to use checksums
f955ff8ad1a8598d39c339ebd9b1401cdaed871e5d9640464d4f39df3ef2c83c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

Security for dbreak 0.0.1

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

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