Last active
October 25, 2019 08:10
-
-
Save martinlechner1/d4ce271ce96d485db01496add6a1b58f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def buildTransactor(c: Connection): Resource[IO, Transactor[IO]] = | |
Blocker[IO].map { b => | |
Transactor.fromConnection[IO](c, b) | |
} | |
private def prestoTransactor(): Resource[IO, Transactor[IO]] = | |
Resource.fromAutoCloseable[IO, Connection] { | |
IO.fromTry(Try { | |
val url = "jdbc:presto://your-presto-jdbc-url" | |
val properties = new Properties() | |
properties.setProperty("user", System.getenv("PRESTO_USER")) | |
properties.setProperty("password", System.getenv("PRESTO_PW")) | |
val connection = DriverManager.getConnection(url, properties) | |
connection.setSchema("your_schema") | |
connection.setAutoCommit(true) | |
connection | |
}) | |
} | |
.flatMap(buildTransactor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment