Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

andriimartynov/zio-jasync-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zio-jasync-sql

Download Build Status Apache License V.2

Scala wrapper for jasync-sql a Simple, Netty based, asynchronous, performant and reliable database drivers for PostgreSQL and MySQL.

Getting zio-jasync-sql

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"

Usage example

// 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.