glodbc

Types

pub type ODBCCommitMode {
  Commit
  Rollback
}

Constructors

  • Commit
  • Rollback
pub type ODBCOption {
  AutoCommit
  BinaryStrings
  TupleRow
  ScrollableCursors
  TraceDriver
  ExtendedErrors
}

Constructors

  • AutoCommit
  • BinaryStrings
  • TupleRow
  • ScrollableCursors
  • TraceDriver
  • ExtendedErrors
pub type ODBCQueryParam {
  Char(values: List(glodbc_ffi.Value), size: Int)
  Wchar(values: List(glodbc_ffi.Value), size: Int)
  Numeric(
    values: List(glodbc_ffi.Value),
    precision: Int,
    scale: Int,
  )
  Decimal(
    values: List(glodbc_ffi.Value),
    precision: Int,
    scale: Int,
  )
  Integer(values: List(glodbc_ffi.Value))
  Smallint(values: List(glodbc_ffi.Value))
  Float(values: List(glodbc_ffi.Value), precision: Int)
  Real(values: List(glodbc_ffi.Value))
  Double(values: List(glodbc_ffi.Value))
  Varchar(values: List(glodbc_ffi.Value), size: Int)
  Wvarchar(values: List(glodbc_ffi.Value), size: Int)
  Date(values: List(glodbc_ffi.Value))
  Time(values: List(glodbc_ffi.Value))
  Timestamp(values: List(glodbc_ffi.Value))
  Longvarchar(values: List(glodbc_ffi.Value), size: Int)
  Wlongvarchar(values: List(glodbc_ffi.Value), size: Int)
  Binary(values: List(glodbc_ffi.Value))
  Varbinary(values: List(glodbc_ffi.Value))
  Longvarbinary(values: List(glodbc_ffi.Value))
  Tinyint(values: List(glodbc_ffi.Value))
  Bit(values: List(glodbc_ffi.Value))
}

Constructors

For erlang functions when they return ok

pub type ODBCSuccess {
  ODBCOk
}

Constructors

  • ODBCOk
pub type OptionSwitch {
  On
  Off
}

Constructors

  • On
  • Off
pub type QueryResult {
  Updated(rows: Int)
  Selected(col_names: List(String), rows: List(Row))
}

Constructors

  • Updated(rows: Int)
  • Selected(col_names: List(String), rows: List(Row))
pub type Row

Values

pub fn binary(s: String) -> ODBCQueryParam
pub fn bit(i: Int) -> ODBCQueryParam
pub fn char(c: String, size: Int) -> ODBCQueryParam
pub fn commit(
  connection: glodbc_ffi.Connection,
  commit_mode: ODBCCommitMode,
) -> Result(ODBCSuccess, glodbc_ffi.ODBCError)
pub fn connect(
  connection_string: String,
  options: List(#(ODBCOption, Bool)),
) -> Result(glodbc_ffi.Connection, glodbc_ffi.ODBCError)

Connect to a database with a connection string and options

Example:

let connstring = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"
let assert Ok(conn) = connect(connstring, [#(AutoCommit, True)])
pub fn date(s: String) -> ODBCQueryParam
pub fn decimal(i: Float, prec: Int, size: Int) -> ODBCQueryParam
pub fn default_options() -> dict.Dict(ODBCOption, OptionSwitch)
pub fn describe_table(
  conn: glodbc_ffi.Connection,
  table: String,
) -> Result(
  List(glodbc_ffi.ODBCDescription),
  glodbc_ffi.ODBCError,
)
pub fn disconnect(
  connection: glodbc_ffi.Connection,
) -> Result(ODBCSuccess, glodbc_ffi.ODBCError)
pub fn double(i: Int) -> ODBCQueryParam
pub fn float(i: Float, prec: Int) -> ODBCQueryParam
pub fn integer(i: Int) -> ODBCQueryParam
pub fn longvarbinary(s: String) -> ODBCQueryParam
pub fn longvarchar(s: String, size: Int) -> ODBCQueryParam
pub fn main() -> Result(ODBCSuccess, glodbc_ffi.ODBCError)
pub fn numeric(
  i: numeric,
  prec: Int,
  size: Int,
) -> ODBCQueryParam
pub fn param_query(
  connection: glodbc_ffi.Connection,
  sql_query: String,
  params: List(List(ODBCQueryParam)),
) -> Result(QueryResult, glodbc_ffi.ODBCError)
pub fn paramlist_to_erlparamlist(
  paramlist: List(List(ODBCQueryParam)),
) -> List(ODBCQueryParam)

I know now a good name but its NOT for public use :) asserts that each row is the same length and is not empty

pub fn real(i: Int) -> ODBCQueryParam
pub fn select(
  conn: glodbc_ffi.Connection,
  position: glodbc_ffi.ODBCSelectPosition,
  n: Int,
) -> Result(Result(a, b), glodbc_ffi.ODBCError)
pub fn select_count(
  conn: glodbc_ffi.Connection,
  query: String,
) -> Result(Int, glodbc_ffi.ODBCError)
pub fn smallint(i: Int) -> ODBCQueryParam
pub fn sql_query(
  connection: glodbc_ffi.Connection,
  sql_query: String,
) -> Result(QueryResult, glodbc_ffi.ODBCError)
pub fn time(s: String) -> ODBCQueryParam
pub fn timestamp(
  dt: #(#(Int, Int, Int), #(Int, Int, Int)),
) -> ODBCQueryParam
pub fn tinyint(i: Int) -> ODBCQueryParam
pub fn varbinary(s: String) -> ODBCQueryParam
pub fn varchar(s: String, size: Int) -> ODBCQueryParam
pub fn wchar(s: String, size: Int) -> ODBCQueryParam
pub fn wlongvarchar(s: String, size: Int) -> ODBCQueryParam
pub fn wvarchar(s: String, size: Int) -> ODBCQueryParam
Search Document