Packages
cake
0.1.0
4.1.0
4.0.0
3.0.0
2.2.2
2.2.1
2.2.0
2.1.3
2.1.2
2.1.1
2.1.0
2.0.2
2.0.1
2.0.0
1.1.2
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc.0
retired
0.15.0
retired
0.14.0
retired
0.13.0
retired
0.12.0
retired
0.11.0
retired
0.10.1
retired
0.10.0
retired
0.9.2
retired
0.9.1
retired
0.9.0
retired
0.8.0
retired
0.7.0
retired
0.6.0
retired
0.5.0
retired
0.4.0
retired
0.3.0
retired
0.2.0
retired
0.1.0
retired
0.0.1
retired
🎂 An SQL query builder for Gleam for SQL dialects 🐘PostgreSQL, 🪶SQLite, 🦭MariaDB, and 🐬MySQL
Retired package: Deprecated - a stable release is available, please use >= 1.0.0
Current section
Files
Jump to
Current section
Files
src/cake@adapter@sqlite_adapter.erl
-module(cake@adapter@sqlite_adapter).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([with_memory_connection/1, execute/2, to_prepared_statement/1, run_query/3]).
-spec with_memory_connection(fun((sqlight:connection()) -> OGD)) -> OGD.
with_memory_connection(Callback_fun) ->
sqlight:with_connection(<<":memory:"/utf8>>, Callback_fun).
-spec execute(binary(), sqlight:connection()) -> {ok, nil} |
{error, sqlight:error()}.
execute(Query, Conn) ->
_pipe = Query,
sqlight:exec(_pipe, Conn).
-spec to_prepared_statement(cake@internal@query:'query'()) -> cake@internal@prepared_statement:prepared_statement().
to_prepared_statement(Qry) ->
_pipe = Qry,
cake@internal@query:builder_new(_pipe, <<"?"/utf8>>).
-spec run_query(
sqlight:connection(),
cake@internal@query:'query'(),
fun((gleam@dynamic:dynamic_()) -> {ok, OGM} |
{error, list(gleam@dynamic:decode_error())})
) -> {ok, list(OGM)} | {error, sqlight:error()}.
run_query(Db_conn, Qry, Dcdr) ->
Prp_stm = to_prepared_statement(Qry),
Sql = begin
_pipe = cake@internal@prepared_statement:get_sql(Prp_stm),
cake@stdlib@iox:dbg(_pipe)
end,
Params = cake@internal@prepared_statement:get_params(Prp_stm),
Db_params = begin
_pipe@1 = Params,
_pipe@2 = gleam@list:map(_pipe@1, fun(Param) -> case Param of
{bool_param, Param@1} ->
sqlight:bool(Param@1);
{float_param, Param@2} ->
sqlight:float(Param@2);
{int_param, Param@3} ->
sqlight:int(Param@3);
{string_param, Param@4} ->
sqlight:text(Param@4)
end end),
_pipe@3 = cake@stdlib@iox:print_tap(_pipe@2, <<"Params: "/utf8>>),
cake@stdlib@iox:dbg(_pipe@3)
end,
_pipe@4 = Sql,
sqlight:'query'(_pipe@4, Db_conn, Db_params, Dcdr).