Skip to main content

Test Database Builder for Python (TDBP) is a lightweight framework that simplifies database integration testing by providing a fluent API for creating test database objects and test data.

It helps developers write cleaner, more maintainable database integration tests by eliminating boilerplate code and providing a consistent way to set up test data.

TDBP promotes the concept of disposable test setups. The compact code encourages keeping each test independent by having it create its own test dataset. This also makes reviews much easier, since setup execution and assertions are close to each other.

Please note that TDBP aims at functional tests, where the amount of data required for each test is usually small. If you need to test with large amounts of data, TDBP is not the right approach. It is especially ill-suited for performance testing.

This project is inspired by Exasol’s Test Database Builder for Java (https://github.com/exasol/test-db-builder-java).

Target Audience

TDBP is designed for:

  • Software developers writing database integration tests

  • QA engineers automating database tests

  • Database developers testing stored procedures and functions

  • Anyone needing to create temporary test database objects and data

Quick Start

We recommend to make the object factory a fixture in your integration test and purge the database before each test. This ensures test isolation.

The object factory needs a database connection. In case of the Exasol dialect, the pytest-exasol-backend (https://github.com/exasol/pytest-backend) makes creating an Exasol backend and getting a connection very convenient.

@pytest.fixture
def factory(connection):
    factory = ExasolObjectFactory(connection)
    factory.purge_user_objects()  # Clean slate for each test
    return factory

With that done, the test preparation gets very compact.

def test_insert_customers(factory):
    # Prepare the test database
    schema = factory.create_schema("SALES")
    table = schema.create_table("CUSTOMERS",
        ID="DECIMAL(12,0)", NAME="VARCHAR(255)")
    table.insert(1, "Alice").insert(2, "Bob")

    # Execute your test
    # ...

    # Assert the results
    # ...

Information for Users

  • 📖 User Guide: Detailed instructions on using TDBP including examples and best practices

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

test_db_builder_python-1.0.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

test_db_builder_python-1.0.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file test_db_builder_python-1.0.1.tar.gz.

File metadata

  • Download URL: test_db_builder_python-1.0.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.0 CPython/3.12.13 Linux/6.17.0-1020-azure

File hashes

Hashes for test_db_builder_python-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a6be788fa3ec16ac8f3e49e790b8d3705ddbf44a1c60724ca84b9cc35bf0f6d5
MD5 a1f3c8920bc07ab8a6e61d2503157faa
BLAKE2b-256 8c41c51f15f4e7bdaab9ecd61f1ac1de630ed80282dd8d75ad1e2e2726d4aa3c

See more details on using hashes here.

File details

Details for the file test_db_builder_python-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for test_db_builder_python-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a162eb11ae6530e438d4a85622126c19a84aa8af80fa606da591dcff6b1b67f0
MD5 77df1c6c20bbf2ed51335a1bd941c148
BLAKE2b-256 5936d4b932d422b904b80c67094d43adde07a5d631971510c9891e09938648d2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

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