Session

skunk.Session
See theSession companion object
trait Session[F[_]]

Represents a live connection to a Postgres database. Operations provided here are safe to use concurrently. Note that this is a lifetime-managed resource and as such is invalid outside the scope of its owning Resource, as are any streams constructed here. If you start an operation be sure to join its Fiber before releasing the resource.

See the companion object for information on obtaining a pooled or single-use instance.

Attributes

Companion:
object
Source:
Session.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Impl[F]

Members list

Concise view

Queries

A query is any SQL statement that returns rows; i.e., any SELECT or VALUES query, or an INSERT, UPDATE, or DELETE command that returns rows via RETURNING. Parameterized queries must first be prepared, then can be executed many times with different arguments. Non-parameterized queries can be executed directly.

def cursor[A, B](query: Query[A, B], args: A): Resource[F, Cursor[F, B]]

Prepare if needed, then execute a parameterized query and returns a resource wrapping a cursor in the result set.

Prepare if needed, then execute a parameterized query and returns a resource wrapping a cursor in the result set.

Attributes

Source:
Session.scala
def execute[A](query: Query[Void, A]): F[List[A]]

Execute a non-parameterized query and yield all results. If you have parameters or wish to limit returned rows use prepare instead.

Execute a non-parameterized query and yield all results. If you have parameters or wish to limit returned rows use prepare instead.

Attributes

Source:
Session.scala
def execute[A, B](query: Query[A, B], args: A): F[List[B]]

Prepare if needed, then execute a parameterized query and yield all results. If you wish to limit returned rows use prepare instead.

Prepare if needed, then execute a parameterized query and yield all results. If you wish to limit returned rows use prepare instead.

Attributes

Source:
Session.scala
def option[A](query: Query[Void, A]): F[Option[A]]

Execute a non-parameterized query and yield at most one row, raising an exception if there are more. If you have parameters use prepare instead.

Execute a non-parameterized query and yield at most one row, raising an exception if there are more. If you have parameters use prepare instead.

Attributes

Source:
Session.scala
def option[A, B](query: Query[A, B], args: A): F[Option[B]]

Prepare if needed, then execute a parameterized query and yield at most one row, raising an exception if there are more.

Prepare if needed, then execute a parameterized query and yield at most one row, raising an exception if there are more.

Attributes

Source:
Session.scala
def prepare[A, B](query: Query[A, B]): F[PreparedQuery[F, A, B]]

Prepares then caches a query, yielding a PreparedQuery which can be executed multiple times with different arguments.

Prepares then caches a query, yielding a PreparedQuery which can be executed multiple times with different arguments.

Attributes

Source:
Session.scala
def prepareR[A, B](query: Query[A, B]): Resource[F, PreparedQuery[F, A, B]]

Resource that prepares a query, yielding a PreparedQuery which can be executed multiple times with different arguments.

Resource that prepares a query, yielding a PreparedQuery which can be executed multiple times with different arguments.

Note: this method only exists to ease migration from Skunk 0.3 and prior. Use the non-resource variant instead.

Attributes

Source:
Session.scala
def unique[A](query: Query[Void, A]): F[A]

Execute a non-parameterized query and yield exactly one row, raising an exception if there are more or fewer. If you have parameters use prepare instead.

Execute a non-parameterized query and yield exactly one row, raising an exception if there are more or fewer. If you have parameters use prepare instead.

Attributes

Source:
Session.scala
def unique[A, B](query: Query[A, B], args: A): F[B]

Prepare if needed, then execute a parameterized query and yield exactly one row, raising an exception if there are more or fewer.

Prepare if needed, then execute a parameterized query and yield exactly one row, raising an exception if there are more or fewer.

Attributes

Source:
Session.scala

Commands

A command is any SQL statement that cannot return rows. Parameterized commands must first be prepared, then can be executed many times with different arguments. Commands without parameters can be executed directly.

def execute(command: Command[Void]): F[Completion]

Execute a non-parameterized command and yield a Completion. If you have parameters use prepare instead.

Execute a non-parameterized command and yield a Completion. If you have parameters use prepare instead.

Attributes

Source:
Session.scala
def execute[A](command: Command[A], args: A): F[Completion]

Prepare if needed, then execute a parameterized command and yield a Completion.

Prepare if needed, then execute a parameterized command and yield a Completion.

Attributes

Source:
Session.scala
def pipe[A](command: Command[A]): (F, A) => Completion

Transform a Command into a Pipe from inputs to Completions.

Transform a Command into a Pipe from inputs to Completions.

Attributes

Source:
Session.scala
def pipe[A, B](query: Query[A, B], chunkSize: Int): (F, A) => B

Transform a Query into a Pipe from inputs to outputs.

Transform a Query into a Pipe from inputs to outputs.

Attributes

chunkSize

how many rows must be fetched by page

Source:
Session.scala
def prepare[A](command: Command[A]): F[PreparedCommand[F, A]]

Prepares then caches an INSERT, UPDATE, or DELETE command that returns no rows. The resulting PreparedCommand can be executed multiple times with different arguments.

Prepares then caches an INSERT, UPDATE, or DELETE command that returns no rows. The resulting PreparedCommand can be executed multiple times with different arguments.

Attributes

Source:
Session.scala
def prepareR[A](command: Command[A]): Resource[F, PreparedCommand[F, A]]

Prepare an INSERT, UPDATE, or DELETE command that returns no rows. The resulting PreparedCommand can be executed multiple times with different arguments.

Prepare an INSERT, UPDATE, or DELETE command that returns no rows. The resulting PreparedCommand can be executed multiple times with different arguments.

Note: this method only exists to ease migration from Skunk 0.3 and prior. Use the non-resource variant instead.

Attributes

Source:
Session.scala
def stream[A, B](command: Query[A, B], args: A, chunkSize: Int): Stream[F, B]

Returns a stream that prepare if needed, then execute a parameterized query

Returns a stream that prepare if needed, then execute a parameterized query

Attributes

chunkSize

how many rows must be fetched by page

Source:
Session.scala

Transactions

Users can manipulate transactions directly via commands like BEGIN and COMMIT, but dealing with cancellation and error conditions can be complicated and repetitive. Skunk provides managed transaction blocks to make this easier.

Resource that wraps a transaction block. A transaction is begun before entering the use block, on success the block is executed, and on exit the following behavior holds.

Resource that wraps a transaction block. A transaction is begun before entering the use block, on success the block is executed, and on exit the following behavior holds.

  • If the block exits normally, and the session transaction status is
    • Active, then the transaction will be committed.
    • Idle, then this means the user terminated the transaction explicitly inside the block and there is nothing to be done.
    • Error then this means the user encountered and handled an error but left the transaction in a failed state, and the transaction will be rolled back.
  • If the block exits due to cancellation or an error and the session transaction status is not Idle then the transaction will be rolled back and any error will be re-raised.

Attributes

Source:
Session.scala

Resource that wraps a transaction block. It has the ability to specify a non-default isolation level and access mode.

Resource that wraps a transaction block. It has the ability to specify a non-default isolation level and access mode.

Attributes

See also:

Session#transaction for more information

Source:
Session.scala

Channels

A named asynchronous channel that can be used for inter-process communication.

A named asynchronous channel that can be used for inter-process communication.

Attributes

Source:
Session.scala

Session Environment

The Postgres session has a dynamic environment that includes a configuration map with keys like TimeZone and server_version, as well as a current TransactionStatus. These can change asynchronously and are exposed as Signals. Note that any Stream based on these signals is only valid for the lifetime of the Session.

def parameter(key: String): Stream[F, String]

Stream (possibly empty) of discrete values for the specified key, via parameters.

Stream (possibly empty) of discrete values for the specified key, via parameters.

Attributes

Source:
Session.scala

Signal representing the current state of all Postgres configuration variables announced to this session. These are sent after authentication and are updated asynchronously if the runtime environment changes. The current keys are as follows (with example values), but these may change with future releases so you should be prepared to handle unexpected ones.

Signal representing the current state of all Postgres configuration variables announced to this session. These are sent after authentication and are updated asynchronously if the runtime environment changes. The current keys are as follows (with example values), but these may change with future releases so you should be prepared to handle unexpected ones.

Map(
 "application_name"            -> "",
 "client_encoding"             -> "UTF8",
 "DateStyle"                   -> "ISO, MDY",
 "integer_datetimes"           -> "on",       // cannot change after startup
 "IntervalStyle"               -> "postgres",
 "is_superuser"                -> "on",
 "server_encoding"             -> "UTF8",     // cannot change after startup
 "server_version"              -> "9.5.3",    // cannot change after startup
 "session_authorization"       -> "postgres",
 "standard_conforming_strings" -> "on",
 "TimeZone"                    -> "US/Pacific",
)

Attributes

Source:
Session.scala

Signal representing the current transaction status.

Signal representing the current transaction status.

Attributes

Source:
Session.scala

Transformations

def mapK[G[_] : MonadCancelThrow](fk: FunctionK[F, G])(implicit evidence$19: MonadCancelThrow[G], mcf: MonadCancel[F, _]): Session[G]
Implicitly added by SessionSyntax

Transform this Session by a given FunctionK.

Transform this Session by a given FunctionK.

Attributes

Source:
Session.scala

Value members

Abstract methods

Each session has access to the pool-wide cache of all statements that have been checked via the Describe protocol, which allows us to skip subsequent checks. Users can inspect and clear the cache through this accessor.

Each session has access to the pool-wide cache of all statements that have been checked via the Describe protocol, which allows us to skip subsequent checks. Users can inspect and clear the cache through this accessor.

Attributes

Source:
Session.scala

Each session has access to a cache of all statements that have been parsed by the Parse protocol, which allows us to skip a network round-trip. Users can inspect and clear the cache through this accessor.

Each session has access to a cache of all statements that have been parsed by the Parse protocol, which allows us to skip a network round-trip. Users can inspect and clear the cache through this accessor.

Attributes

Source:
Session.scala

Attributes

Source:
Session.scala