Scala wrapper for jasync-sql a Simple, Netty based, asynchronous, performant and reliable database drivers for PostgreSQL and MySQL.
To resolve artifacts through Artifactory, simply add the following code snippet to your build.sbt file:
resolvers += Resolver.jcenterRepo
The current version is 1.1.2, which is cross-built against Scala 2.11.x, 2.12.x and 2.13.x.
libraryDependencies += "com.github.andriimartynov" %% "zio-jasync-sql" % "1.1.2"
// Connection to MySQL DB
val connection = MySQLConnectionBuilder.createConnectionPool(
"jdbc:mysql://$host:$port/$database?user=$username&password=$password");
// Connection to PostgreSQL DB
val connection = PostgreSQLConnectionBuilder.createConnectionPool(
"jdbc:postgresql://$host:$port/$database?user=$username&password=$password");
val layer: Layer[Throwable, ConnectionService] =
ConnectionService.live(connection)
val rio: RIO[ConnectionService, QueryResult] = for {
queryResult <- sendPreparedStatement("select * from test limit 2")
} yield queryResult
val task: Task[QueryResult] = rio.provideLayer(layer)
See a full example at zio-jasync-mysql-example and zio-jasync-postgresql-example.