#sqlx #postgresql #database #test


A simple tool to test sqlx database, it automatically create and drop database when the test create and drop

4 releases

0.1.3 Jun 2, 2023
0.1.2 Jun 1, 2023
0.1.1 Jun 1, 2023
0.1.0 Jun 1, 2023

#1762 in Development tools

MIT license

99 lines


This project learns from: https://github.com/tyrchen/sqlx-db-tester/tree/master


This a tool test sqlx with postgres. It only support tokio runtime in this moment.

How to use it

You should first create TestDB data structure in your tests. It will automcatically create a database and a connection pool for you. Then you could get the connection string or connection pool from it to use on your own code. When TestDB gets drop, it will automcatically drop the database.

async fn some_test() {
    let tdb = TestDB::new("postgers://postgrses:postgres@localhost:5432", "./migrations");
    let pool = tdb.get_pool().await;
    // do you test logic

    // the code finish in this test, tdb will drop the database which it create.

Have fun with this crate!


This project is distributed under the terms of MIT license.


~647K SLoC