PostgreSQL

class PostgreSQL(url: String, username: String, password: String, options: <Error class: unknown class> = Driver.Pool.Options())

PostgreSQL class provides mechanisms to interact with a PostgreSQL database. It implements Driver, Driver.Pool, and Driver.Transactional interfaces, offering functionalities such as connection pooling, executing queries, fetching data, and handling transactions.

The URL scheme designator can be either postgresql:// or postgres://. Each of the URL parts is optional.

postgresql:// postgresql://localhost postgresql://localhost:5433 postgresql://localhost/mydb postgresql://user@localhost postgresql://user:secret@localhost postgresql://localhost?dbname=mydb&user=postgres&password=postgres

Parameters

url

The URL of the PostgreSQL database to connect to.

username

The username used for authentication.

password

The password used for authentication.

options

Optional pool configuration, defaulting to Driver.Pool.Options.

Constructors

Link copied to clipboard
constructor(url: String, username: String, password: String, options: <Error class: unknown class> = Driver.Pool.Options())

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class Notification(val channel: String, val value: String)
Link copied to clipboard
class Tx(var tx: <Error class: unknown class><out <Error class: unknown class>>)

Functions

Link copied to clipboard
open suspend fun begin(): <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open suspend fun close(): <Error class: unknown class><Unit>
Link copied to clipboard
open suspend fun execute(statement: <Error class: unknown class>): <Error class: unknown class><Long>
open suspend fun execute(sql: String): <Error class: unknown class><Long>
Link copied to clipboard
open suspend fun fetchAll(statement: <Error class: unknown class>): <Error class: unknown class><<Error class: unknown class>>
open suspend fun fetchAll(sql: String): <Error class: unknown class><<Error class: unknown class>>
open suspend fun <T> fetchAll(statement: <Error class: unknown class>, rowMapper: <Error class: unknown class><T>): <Error class: unknown class><List<T>>
Link copied to clipboard
suspend fun listen(channel: String, f: (PostgreSQL.Notification) -> Unit)
suspend fun listen(channels: List<String>, f: (PostgreSQL.Notification) -> Unit)
Link copied to clipboard
open suspend fun migrate(path: String): <Error class: unknown class><Unit>
Link copied to clipboard
suspend fun notify(channel: String, value: String)

We accept only String values, because only the text type is supported by postgres. https://www.postgresql.org/docs/current/sql-notify.html

Link copied to clipboard
open fun poolIdleSize(): Int
Link copied to clipboard
open fun poolSize(): Int