gdo/driver

Types

pub type Authentication {
  NoAuthentication
  UsernameAndPassword(username: String, password: String)
}

Constructors

  • NoAuthentication
  • UsernameAndPassword(username: String, password: String)
pub type Capability {
  SupportsTransactions
  SupportsLastInsertId
  SupportsPositionalParameters
  SupportsNamedParameters
  SupportsEmbeddedConnections
  SupportsNetworkConnections
  SupportsAuthentication
  SupportsTlsConfiguration
}

Constructors

  • SupportsTransactions
  • SupportsLastInsertId
  • SupportsPositionalParameters
  • SupportsNamedParameters
  • SupportsEmbeddedConnections
  • SupportsNetworkConnections
  • SupportsAuthentication
  • SupportsTlsConfiguration
pub type ConnectionTarget {
  EmbeddedDatabase(path: String)
  ServerDatabase(network: NetworkEndpoint)
}

Constructors

pub type Driver {
  Sqlite
}

Constructors

  • Sqlite
pub type DriverConnectionState {
  SqliteConnectionState(
    database: String,
    connection: sqlight.Connection,
    last_insert_id: option.Option(Int),
  )
}

Constructors

pub type DriverContract {
  DriverContract(
    connect: fn(ConnectionTarget) -> Result(
      DriverConnectionState,
      error.Error,
    ),
    close: fn(DriverConnectionState) -> Result(Nil, error.Error),
    prepare: fn(DriverConnectionState, String) -> Result(
      DriverStatementState,
      error.Error,
    ),
    exec: fn(DriverStatementState, List(value.Param)) -> Result(
      result.ExecutionResult,
      error.Error,
    ),
    query_all: fn(DriverStatementState, List(value.Param)) -> Result(
      result.QueryResult,
      error.Error,
    ),
    begin: fn(DriverConnectionState) -> Result(
      DriverConnectionState,
      error.Error,
    ),
    commit: fn(DriverConnectionState) -> Result(
      DriverConnectionState,
      error.Error,
    ),
    rollback: fn(DriverConnectionState) -> Result(
      DriverConnectionState,
      error.Error,
    ),
    last_insert_id: fn(DriverConnectionState) -> option.Option(
      Int,
    ),
  )
}

Constructors

pub type DriverStatementState {
  SqliteStatementState(
    connection: sqlight.Connection,
    sql: String,
  )
}

Constructors

pub type NetworkEndpoint {
  NetworkEndpoint(
    host: String,
    port: Int,
    database: String,
    authentication: Authentication,
    tls: TransportSecurity,
  )
}

Constructors

pub type TransportSecurity {
  DisableTls
  PreferTls
  RequireTls
}

Constructors

  • DisableTls
  • PreferTls
  • RequireTls

Values

pub fn begin(
  contract: DriverContract,
  connection_state: DriverConnectionState,
) -> Result(DriverConnectionState, error.Error)
pub fn capabilities(driver: Driver) -> List(Capability)
pub fn close(
  contract: DriverContract,
  connection_state: DriverConnectionState,
) -> Result(Nil, error.Error)
pub fn commit(
  contract: DriverContract,
  connection_state: DriverConnectionState,
) -> Result(DriverConnectionState, error.Error)
pub fn connect(
  contract: DriverContract,
  target: ConnectionTarget,
) -> Result(DriverConnectionState, error.Error)
pub fn connection_target_name(target: ConnectionTarget) -> String
pub fn exec(
  contract: DriverContract,
  statement_state: DriverStatementState,
  params: List(value.Param),
) -> Result(result.ExecutionResult, error.Error)
pub fn identifier(target: ConnectionTarget) -> String
pub fn last_insert_id(
  contract: DriverContract,
  connection_state: DriverConnectionState,
) -> option.Option(Int)
pub fn name(driver: Driver) -> String
pub fn prepare(
  contract: DriverContract,
  connection_state: DriverConnectionState,
  sql: String,
) -> Result(DriverStatementState, error.Error)
pub fn query_all(
  contract: DriverContract,
  statement_state: DriverStatementState,
  params: List(value.Param),
) -> Result(result.QueryResult, error.Error)
pub fn rollback(
  contract: DriverContract,
  connection_state: DriverConnectionState,
) -> Result(DriverConnectionState, error.Error)
pub fn supports(
  driver: Driver,
  capability capability: Capability,
) -> Bool
Search Document