Better interface for bulk inserts

This commit is contained in:
Alexey Romanov
2010-10-22 10:26:34 +04:00
parent 3bfd35418c
commit c53f0de508
2 changed files with 93 additions and 27 deletions

View File

@@ -7,14 +7,13 @@
%%%-------------------------------------------------------------------
-module(sqlite3_test).
%%====================================================================
%% ====================================================================
%% API
%%====================================================================
%%--------------------------------------------------------------------
%% ====================================================================
%% --------------------------------------------------------------------
%% Function:
%% Description:
%%--------------------------------------------------------------------
-ifdef(TEST).
%% --------------------------------------------------------------------
-include_lib("eunit/include/eunit.hrl").
drop_all_tables(Db) ->
@@ -84,7 +83,10 @@ select_many_records_test() ->
sqlite3:open(ct),
drop_table_if_exists(ct, many_records),
sqlite3:create_table(ct, many_records, [{id, integer}, {name, text}]),
[sqlite3:write(ct, many_records, [{id, X}, {name, "bar"}]) || X <- lists:seq(1, 1024)], %% takes very long :(
sqlite3:write_many(ct, many_records, [[{id, X}, {name, "bar"}] || X <- lists:seq(1, 1024)]),
%% sqlite3:begin_transaction(ct),
%% [sqlite3:write(ct, many_records, [{id, X}, {name, "bar"}]) || X <- lists:seq(1, 1024)], %% takes very long :(
%% sqlite3:commit_transaction(ct),
Columns = ["id", "name"],
?assertEqual(
[{columns, Columns}, {rows, [{1, <<"bar">>}]}],
@@ -107,8 +109,6 @@ nonexistent_table_info_test() ->
sqlite3:open(ct),
?assertEqual(table_does_not_exist, sqlite3:table_info(ct, nonexistent)),
sqlite3:close(ct).
-endif.
% create, read, update, delete
%%====================================================================