Usage with Fs2
DataPrism has integrations with fs2 in the module dataprism-fs2
to get the results of a query as a stream. The JDBC Implementation for this module can be found in the dataprism-jdbc-fs2
module. To get nice functions to run an Operation
as a stream, you need to create your own platform, and mix in Fs2SqlQueryPlatform
. Here's an example.
import dataprism.jdbc.platform.PostgresJdbcPlatform
import dataprism.platform.sql.Fs2SqlPlatform
object MyPlatform extends PostgresJdbcPlatform, Fs2SqlPlatform {
override type Api = PostgresApi & Fs2Api
object Api extends PostgresApi, Fs2Api
override type Impl = DefaultCompleteImpl & SqlArraysImpl
object Impl extends DefaultCompleteImpl, SqlArraysImpl
}
From there you create the stream aware Db
using a DataSource
like normal.
import dataprism.jdbc.sql.*
import cats.effect.IO
import javax.sql.DataSource
val ds: DataSource = ???
given Fs2DataSourceDb[IO] = new Fs2DataSourceDb(ds)
In this article