sqlitex v1.0.1 Sqlitex
Sqlitex gives you a way to create and query sqlite databases.
Basic Example
iex> {:ok, db} = Sqlitex.open(":memory:")
iex> Sqlitex.exec(db, "CREATE TABLE t (a INTEGER, b INTEGER, c INTEGER)")
:ok
iex> Sqlitex.exec(db, "INSERT INTO t VALUES (1, 2, 3)")
:ok
iex> Sqlitex.query(db, "SELECT * FROM t")
{:ok, [[a: 1, b: 2, c: 3]]}
iex> Sqlitex.query(db, "SELECT * FROM t", into: %{})
{:ok, [%{a: 1, b: 2, c: 3}]}
Summary
Functions
Create a new table name
where table_opts
are a list of table constraints
and cols
are a keyword list of columns. The following table constraints are
supported: :temp
and :primary_key
. Example
Types
connection :: {:connection, reference, String.t}
sqlite_error :: {:error, {:sqlite_error, charlist}}
string_or_charlist :: String.t | charlist
Functions
Create a new table name
where table_opts
are a list of table constraints
and cols
are a keyword list of columns. The following table constraints are
supported: :temp
and :primary_key
. Example:
[:temp, {:primary_key, [:id]}]
Columns can be passed as:
- name: :type
- name: {:type, constraints}
where constraints is a list of column constraints. The following column constraints
are supported: :primary_key
, :not_null
and :autoincrement
. Example:
id: :integer, name: {:text, [:not_null]}
Specs
open(String.t) :: {:ok, connection}
open(charlist) ::
{:ok, connection} |
{:error, {atom, charlist}}