ZioJdbcContext
Quill context that executes JDBC queries inside of ZIO. Unlike most other contexts
that require passing in a Data Source, this context takes in a java.sql.Connection
as a resource dependency which can be provided later (see ZioJdbc
for helper methods
that assist in doing this).
Quill context that executes JDBC queries inside of ZIO. Unlike most other contexts
that require passing in a Data Source, this context takes in a java.sql.Connection
as a resource dependency which can be provided later (see ZioJdbc
for helper methods
that assist in doing this).
The resource dependency itself is not just a Connection since JDBC requires blocking.
Instead it is a Has[Connection] with Has[Blocking.Service]
which is type-alised as
QConnection
hence methods in this context return ZIO[QConnection, Throwable, T]
.
The type QIO[T]
i.e. Quill-IO is an alias for this.
If you have a zio-app, using this context is fairly straightforward but requires some setup: {{ val zioConn = ZLayer.fromManaged(for { ds <- ZManaged.fromAutoCloseable(Task(JdbcContextConfig(LoadConfig("testPostgresDB")).dataSource)) conn <- ZManaged.fromAutoCloseable(Task(ds.getConnection)) } yield conn)
MyZioContext.run(query[Person]).provideCustomLayer(zioConn) }}
Various methods in the io.getquill.context.ZioJdbc
can assist in simplifying it's creation, for example, you can
provide a DataSource
instead of a Connection
like this
(note that the resulting Connection has a closing bracket).
{{
import ZioJdbc._
val zioConn = QDataSource.fromPrefix("testPostgresDB") >>> QDataSource.toConnection
MyZioContext.run(query[Person]).provideCustomLayer(zioConn)
}}
If you are using a Plain Scala app however, you will need to manually run it e.g. using zio.Runtime {{ Runtime.default.unsafeRun(MyZioContext.run(query[Person]).provideCustomLayer(zioConn)) }}
Type members
Classlikes
In order to allow a ResultSet to be consumed by an Observable, a ResultSet iterator must be created. Since Quill provides a extractor for an individual ResultSet row, a single row can easily be cached in memory. This allows for a straightforward implementation of a hasNext method.
In order to allow a ResultSet to be consumed by an Observable, a ResultSet iterator must be created. Since Quill provides a extractor for an individual ResultSet row, a single row can easily be cached in memory. This allows for a straightforward implementation of a hasNext method.
Inherited classlikes
- Inherited from
- ProtoContext
Types
Inherited types
Value members
Concrete methods
ZIO Contexts do not managed DB connections so this is a no-op
ZIO Contexts do not managed DB connections so this is a no-op
- Definition Classes
- Context -> Closeable -> AutoCloseable
Override to enable specific vendor options needed for streaming
Override to enable specific vendor options needed for streaming
Inherited methods
- Definition Classes
- JdbcRunContext -> ProtoContext
- Inherited from
- JdbcRunContext
- Definition Classes
- JdbcRunContext -> ProtoContext
- Inherited from
- JdbcRunContext
- Definition Classes
- JdbcRunContext -> ProtoContext
- Inherited from
- JdbcRunContext
- Inherited from
- JdbcRunContext
- Definition Classes
- JdbcRunContext -> ProtoContext
- Inherited from
- JdbcRunContext
- Definition Classes
- JdbcRunContext -> ProtoContext
- Inherited from
- JdbcRunContext
- Inherited from
- EncodingDsl
- Inherited from
- EncodingDsl
Parses instances of java.sql.Types to string form so it can be used in creation of sql arrays. Some databases does not support each of generic types, hence it's welcome to override this method and provide alternatives to non-existent types.
Parses instances of java.sql.Types to string form so it can be used in creation of sql arrays. Some databases does not support each of generic types, hence it's welcome to override this method and provide alternatives to non-existent types.
- Value Params
- intType
one of java.sql.Types
- Returns
JDBC type in string form
- Inherited from
- JdbcRunContext
- Inherited from
- PrepareContext
- Inherited from
- ZioPrepareContext
- Inherited from
- ZioPrepareContext
- Inherited from
- ZioPrepareContext
Execute SQL on connection and return prepared statement. Closes the statement in a bracket.
Execute SQL on connection and return prepared statement. Closes the statement in a bracket.
- Inherited from
- ZioPrepareContext
- Inherited from
- JdbcRunContext
- Inherited from
- Context
- Inherited from
- Context
- Inherited from
- Context
Concrete fields
Inherited fields
Extensions
Inherited extensions
Implicits
Inherited implicits
- Definition Classes
- Encoders -> EncodingDsl
- Inherited from
- Encoders