A single-transaction based SQL driver for Go that provides immutable transaction isolation for functional testing.
go-txdb is a specialized SQL driver for Go that wraps any standard sql.Driver connection to operate within a single transaction. It is primarily designed for functional testing, allowing tests to run in isolated transactions without affecting the underlying database state, which makes tests fast and repeatable.
Go developers writing functional or integration tests that require database access, particularly those using MySQL or PostgreSQL who need isolated test environments.
Developers choose go-txdb because it provides transactional isolation for tests without requiring code changes to existing sql.DB usage, eliminating the need to reload or reset databases between tests and ensuring speed and reliability.
Immutable transaction isolated sql driver for golang
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Each database connection in tests operates within a transaction that is automatically rolled back on close, ensuring no side effects on the database state, as described in the README for fast, repeatable tests.
Uses locking to handle concurrent database operations in tests, with connections properly released to prevent leaks, making it reliable for multi-threaded testing scenarios.
Wraps any standard SQL driver like MySQL or PostgreSQL, allowing flexibility in database backends without code changes, as shown in the registration examples.
Implements the standard sql.Driver interface, so existing code using sql.DB requires no modifications, enabling easy adoption for functional testing.
Designed solely for testing with all transactions rolled back, so it cannot be used in production or any scenario requiring data persistence.
Does not support testing commit semantics or advanced transaction features, as it always operates within a single rolled-back transaction, which may not cover all use cases.
Requires configuration of database DSNs and potentially tools like testcontainers, adding complexity to test environment setup, especially in CI/CD pipelines.