Skip to content

Kuzminki is feature-rich query builder and access library for PostgreSQL written in Scala.

License

Notifications You must be signed in to change notification settings

karimagnusson/kuzminki-pekko

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter URL

kuzminki-pekko

About

This project adds support for Pekko streaming to kuzminki-ec. Take a look at the kuzminki-play-demo for an example of usage.

If you are using Akka, you can use version 0.9.3

Sbt

// available for Scala 2.13 and Scala 3
libraryDependencies += "io.github.karimagnusson" %% "kuzminki-pekko" % "0.9.5"

Examples

Query as Source.

import kuzminki.pekko.stream._

sql
  .select(user)
  .cols2(t => (
    t.name,
    t.email
  ))
  .all
  .orderBy(_.name.asc)
  .stream
  .map(doSmothing)
  .runWith(mySink)

// By default the source will fetch 100 rows each time.
// To fetch a different number of rows: .stream(1000)

// To get a stream where the tuple is read into a type.
.streamType[MyType]

Query as Sink.

import kuzminki.akka.stream._

val insertUserStm = sql
  .insert(user)
  .cols2(t => (
    t.name,
    t.email
  ))
  .cache

Source(someData)
  .map(doSmothing)
  .runWith(insertUserStm.asSink)

// To insert in batches of 100

Source(someData)
  .map(doSmothing)
  .grouped(100) // insert 100 in each transaction.
  .runWith(insertUserStm.asChunkSink)

// To create a sink that takes a type
insertUserStm.asTypeSink[MyType]

About

Kuzminki is feature-rich query builder and access library for PostgreSQL written in Scala.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages