package sapi
Provides a Scala API for database connectivity.
Main class is a Connection that can be obtained using a ConnectionFactory.
- Alphabetic
- By Inheritance
- sapi
- ImplicitsTrait
- SqlParamImplicits
- InterpolatorsTrait
- SqlInterpolatorTrait
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
case class
ColumnMetadata
(name: String, dbTypeId: String, cls: Option[Class[_]]) extends Product with Serializable
Represents metadata of a database column.
Represents metadata of a database column.
- name
column name
- dbTypeId
database vendor identifier of a datatype declared for the column
- cls
JVM class that a database driver uses to represent values of the column
-
trait
Connection
extends AnyRef
Represents a database connection (session).
Represents a database connection (session).
Instances of implementations of this trait can be obtained using a ConnectionFactory. When clients are done with the connection, they are required to call a
release
method co clean up resources such as open sockets.Invoking any method of this trait when any previous operation has not completed yet is not allowed. Operation is considered complete when a resulting Future completes.
Transaction management has to be done using
beginTx
,commitTx
androllbackTx
methods. Using SQL statements to manage transaction state is not allowed.SqlWithParams instances passed to
Connection
's methods can be created usingsql
string interpolator, for example:import io.rdbc.sapi._ val conn: Connection = ??? val login = "jdoe" conn.statement(sql"select * from users where login = $login").executeForStream()
Alternatively, when bare Strings are used as SQL statements, parameters are specified by name. Parameter name is an alphanumeric string starting with a letter, prefixed with a colon. Example:
import io.rdbc.sapi._ val conn: Connection = ??? val login = "jdoe" conn.statement(sql"select * from users where login = :login") .bind("login" -> login) .executable.executeForStream()
-
trait
ConnectionFactory
extends AnyRef
Provides access to a database Connection.
Provides access to a database Connection.
Implementors must make the implementation of this trait thread-safe.
- implicit class Duration2Timeout extends AnyRef
-
trait
ExecutableStatement
extends AnyRef
Represents an executable statement.
Represents an executable statement.
Executable statement is a statement that has all parameters provided and is ready to be executed.
- trait InterpolatorsTrait extends SqlInterpolatorTrait
-
sealed
trait
KeyColumns
extends AnyRef
Specification of columns that generate keys
-
case class
NotNullParam
[A](v: A) extends SqlParam[A] with Product with Serializable
Not null parameter value.
-
case class
NullParam
[A](cls: Class[A]) extends SqlParam[A] with Product with Serializable
Null parameter value
-
implicit
class
Opt2OptParam[A] extends AnyRef
- Definition Classes
- SqlParamImplicits
-
class
ResultSet
extends Traversable[Row]
Represents a set of rows returned by a database engine.
-
trait
Row
extends AnyRef
Represents a row of a result returned by a database engine.
Represents a row of a result returned by a database engine.
This class defines a set of methods that can be used to get values from the row either by a column name or by a column index. Each method has a version returning an Option to allow null-safe handling of SQL
null
values. -
case class
RowMetadata
(columns: ImmutIndexedSeq[ColumnMetadata]) extends Product with Serializable
Represents a row meta data.
Represents a row meta data.
- columns
meta data for every row column
-
trait
RowPublisher
extends Publisher[Row]
A reactive streams specification's
Publisher
giving access to the rows.A reactive streams specification's
Publisher
giving access to the rows.When this publisher signals that it is complete clients can safely assume that a database is ready to accept new queries. If subscription is cancelled, however, clients have to wait for Connection.watchForIdle future to complete before issuing another query.
- trait SqlInterpolatorTrait extends AnyRef
-
implicit
class
SqlInterpolator
extends AnyRef
- Definition Classes
- SqlInterpolatorTrait
-
sealed
trait
SqlNumeric
extends AnyRef
General unbounded numeric type that extends BigDecimal to be able to represent NaN, positive infitnity and negative infinity.
-
sealed
trait
SqlParam
[A] extends AnyRef
A statement parameter that can represent null (empty) values.
A statement parameter that can represent null (empty) values.
This trait is analogous to standard Option, but keeps type information for empty values. In some cases database engine cannot infer null parameter type - instances of this trait can be used then.
An implicit conversion is provided from Option to instances of this trait - see Opt2OptParam.
This trait does not provide any operations. It is recommended to use Option instances and at the final stage convert them to instances of this trait when passed as statement parameters.
-
case class
SqlWithParams
(sql: String, params: ImmutIndexedSeq[Any]) extends Product with Serializable
Represent a sql statement along with parameters.
Represent a sql statement along with parameters. Instances of this class are supposed to be constructed using
sql
string interpolator like this:import io.rdbc.sapi._ val id = 0 val s: SqlWithParams = sql"select * from test where id = $id"
Instances created by the interpolator can be composed:
import io.rdbc.sapi._ val x = 0 val y = 0 val s: SqlWithParams = sql"select * from test where x = $x" + sql"and y = $y"
-
trait
Statement
extends AnyRef
Represent a SQL statement
Represent a SQL statement
Methods of this trait allow to bind argument values to parameters either by name or index. Classes extending this trait can be used as an alternative to
sql
string interpolator - SqlInterpolator. -
final
case class
StatementOptions
(generatedKeyCols: KeyColumns) extends Product with Serializable
Statement options.
Statement options.
- generatedKeyCols
says what keys generated by the database should be returned
-
final
case class
Timeout
(value: Duration) extends AnyVal with Product with Serializable
Represents a timeout
Represents a timeout
- Annotations
- @implicitNotFound( ... )
-
trait
TypeConverter
[T] extends AnyRef
Represents a converter of values returned by database to type desired by a client.
Represents a converter of values returned by database to type desired by a client.
- T
conversion's target type
-
class
TypeConverterRegistry
extends AnyRef
A registry holding a map of type converters.
- trait TypeConvertersProvider extends AnyRef
-
final
case class
Warning
(msg: String, code: String) extends Product with Serializable
Represents a warning emitted by a database engine during statement processing.
Represents a warning emitted by a database engine during statement processing.
- msg
database vendor specific warning message
- code
database vendor specific warning code
Value Members
-
object
BuildInfo
extends Product with Serializable
This object was generated by sbt-buildinfo.
-
object
Interpolators
extends InterpolatorsTrait
String interpolators
- object KeyColumns
- object SqlNumeric
- object SqlParam extends SqlParamImplicits
- object StatementOptions extends Serializable
-
object
Timeout
extends Serializable
Timeout companion
-
object
TypeConverterRegistry
Factory of TypeConverterRegistry
TODO