Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.