Questions tagged [doobie]
Doobie is a pure functional JDBC layer for Scala and Cats.
doobie
105
questions
4
votes
1
answer
373
views
How to connect to Hive using doobie
There is a jdbc driver for hive but seems not fully functioning. I used the default doobie Transactor to connect to it like
val xa = Transactor.fromDriverManager[IO](
"org.apache.hive.jdbc....
0
votes
1
answer
720
views
How do I create a Doobie Meta instance for MySQL using Play JSON?
How do I implement basic serialization/deserialization at the query level using Doobie, MySQL, and Play JSON?
9
votes
1
answer
2k
views
Doobie transact over a list of ConnectionIO programs
Let's say I have a list of Doobie programs (all with Unit type parameters, fwiw):
val progList: List[ConnectionIO[Unit]] = prog1 :: prog2 :: ... :: Nil
Is there any way I can run them in one ...
0
votes
2
answers
172
views
List to multiple anonymous/underscore parameters in for-comprehension
I'm kind of new to Scala/functional so I'm not yet able to use technical language.
I'm experiencing problems with a for-comprehension
val queries =
for {
_ <- createBanco
_ <- ...
14
votes
1
answer
1k
views
Running queries in parallel in Doobie
Is it possible to run multiple queries in parallel, using Doobie?
I have the following (pseudo)queries:
def prepareForQuery(input: String): ConnectionIO[Unit] = ???
val gettAllResults: ...
0
votes
1
answer
688
views
Scala Doobie query hardcoded values
When writing the following query in Doobie :
(SELECT id FROM (VALUES(?),(?),(?)) table(id))
UNION
SELECT id FROM table
I have list of data , e.g. List(1,2,3,4) that is varied-size.
How could I ...
17
votes
1
answer
5k
views
Doobie and DB access composition within 1 transaction
Doobie book says that it's a good practice to return ConnectionIO from your repository layer. It gives an ability to chain calls and perform them in one transaction.
Nice and clear.
Now let's ...
0
votes
2
answers
1k
views
Create list of case class instances
I have 3 vals, each of type Array[String]
they are all equal in length
val1.length == val2.length // true
Next, I created a case class as following:
case class resource(name: String, count: Int, ...
5
votes
2
answers
2k
views
Compose optional queries for for-comprehension in doobie?
I would like to run several queries in one transaction using a for-comprehension in doobie. Something like:
def addImage(path:String) : ConnectionIO[Image] = {
sql"INSERT INTO images(path) VALUES($...
4
votes
1
answer
3k
views
Doobie with Hikari setup
I want to get the hikari transactor setup to act just like the standard transactor
val xa = HikariTransactor.newHikariTransactor[IO](
"com.mysql.jdbc.Driver",
JdbcUrl,
Username,
...
0
votes
1
answer
1k
views
Transforming Doobie ConnectionIO[Option[Int]] without explicit match
I have a ConnectionIO[Option[Int]] and map over the Option to produce a ConnectionIO[Option[String]] with a query the Some[Int] otherwise keep the Nones. I was able to do this with aforcomprehension ...
13
votes
3
answers
2k
views
Scala doobie fragment with generic type parameter
I am trying to abstract inserting objects of different types into sql tables of similar structure. Here's what I'm trying to do:
class TableAccess[A : Meta](table: String) {
def insert(key: String, ...
3
votes
2
answers
3k
views
How to correctly handle Hikari connection pool with Doobie
I've been using doobie (cats) to connect to a postgresql database from a scalatra application. Recently I noticed that the app was creating a new connection pool for every transaction. I eventually ...
0
votes
1
answer
283
views
Scala (doobie): Type is invariant
I'm working on a project with Scala and doobie. I'm trying to implement a transactor trait that may be injected by MacWire and used with different Task/Future monads (e.g. for tests).
import doobie....
2
votes
0
answers
623
views
Doobie streaming query causes invalid operation
Doobie
Without much experience in either Scala or Doobie I am trying to select data from a DB2 database. Following query works fine and prints as expected 5 employees.
import doobie.imports._, ...