Browse files

sqlite_port is found relative to the sqlite module path.

the db is created in the priv folder unless specified in options.
  • Loading branch information...
1 parent a2e6238 commit 0e86d25797abae26740083447597601bb3e90342 @benbro committed Oct 1, 2009
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/sqlite.erl
View
7 src/sqlite.erl
@@ -86,7 +86,9 @@ start_link(Db, Options) ->
%%--------------------------------------------------------------------
-spec(open/1::(atom()) -> result()).
open(Db) ->
- ?MODULE:open(Db, [{db, "./" ++ atom_to_list(Db) ++ ".db"}]).
+ %?MODULE:open(Db, [{db, "./" ++ atom_to_list(Db) ++ ".db"}]).
+ DbFile = filename:join([filename:dirname(code:which(?MODULE)), "..", "priv", atom_to_list(Db)++".db"]),
+ ?MODULE:open(Db, [{db, DbFile}]).
%%--------------------------------------------------------------------
%% @spec open(Db::atom(), Options::[tuple()]) -> {ok, Pid::pid()} | ignore | {error, Error}
@@ -451,7 +453,8 @@ code_change(_OldVsn, State, _Extra) ->
%%--------------------------------------------------------------------
create_cmd(Dbase) ->
- code:priv_dir(sqlite) ++ "/sqlite_port " ++ Dbase.
+ %code:priv_dir(sqlite) ++ "/sqlite_port " ++ Dbase.
+ filename:join([filename:dirname(code:which(?MODULE)), "..", "priv", ".", "sqlite_port"]) ++ " " ++ Dbase.
exec(Port, Cmd) ->
port_command(Port, term_to_binary(Cmd)),

0 comments on commit 0e86d25

Please sign in to comment.