More efficient sqlite3:write_many

This commit is contained in:
Alexey Romanov
2011-05-10 14:23:33 +04:00
parent 77a00ae1c1
commit b7b9c5e422

View File

@@ -921,9 +921,11 @@ handle_call({write, Tbl, Data}, _From, State) ->
{reply, {error, Exception}, State} {reply, {error, Exception}, State}
end; end;
handle_call({write_many, Tbl, DataList}, _From, State) -> handle_call({write_many, Tbl, DataList}, _From, State) ->
do_sql_exec("BEGIN;", State), SQLScript = ["BEGIN;",
[do_sql_exec(sqlite3_lib:write_sql(Tbl, Data), State) || Data <- DataList], [sqlite3_lib:write_sql(Tbl, Data) || Data <- DataList],
do_handle_call_sql_exec("COMMIT;", State); "COMMIT;"],
Reply = do_sql_exec_script(SQLScript, State),
{reply, Reply, State};
handle_call({read, Tbl}, _From, State) -> handle_call({read, Tbl}, _From, State) ->
% select * from Tbl where Key = Value; % select * from Tbl where Key = Value;
try sqlite3_lib:read_sql(Tbl) of try sqlite3_lib:read_sql(Tbl) of