Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 1.8% on proxy.golang.org
Top 0.3% dependent packages on proxy.golang.org
Top 0.3% dependent repos on proxy.golang.org
Top 3.8% forks on proxy.golang.org

proxy.golang.org : github.com/DATA-DOG/go-txdb

Package txdb is a single transaction based database sql driver. When the connection is opened, it starts a transaction and all operations performed on this *sql.DB will be within that transaction. If concurrent actions are performed, the lock is acquired and connection is always released the statements and rows are not holding the connection. Why is it useful. A very basic use case would be if you want to make functional tests you can prepare a test database and within each test you do not have to reload a database. All tests are isolated within transaction and though, performs fast. And you do not have to interface your sql.DB reference in your code, txdb is like a standard sql.Driver. This driver supports any sql.Driver connection to be opened. You can register txdb for different sql drivers and have it under different driver names. Under the hood whenever a txdb driver is opened, it attempts to open a real connection and starts transaction. When close is called, it rollbacks transaction leaving your prepared test database in the same state as before. Given, you have a mysql database called txdb_test and a table users with a username column. Example: Every time you will run this application, it will remain in the same state as before.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/%21d%21a%21t%21a-%21d%21o%21g/go-txdb
Keywords: go, golang, integration-testing, sql, sql-driver, tdd, testing
License: BSD-3-Clause
Latest release: 5 months ago
First release: over 6 years ago
Namespace: github.com/DATA-DOG
Dependent packages: 148
Dependent repositories: 471
Stars: 519 on GitHub
Forks: 37 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: about 7 hours ago

    Loading...
    Readme
    Loading...