Comparison

plugins/mod_storage_sql.lua @ 4096:3b991ceb228e

mod_storage_sql: Make the 'database' value for the SQLite3 driver relative to the data path
author Matthew Wild <mwild1@gmail.com>
date Fri, 07 Jan 2011 11:57:48 +0000
parent 4073:79fd38ab224b
child 4101:06778bc27d53
comparison
equal deleted inserted replaced
4095:6ad7ed619d37 4096:3b991ceb228e
30 30
31 local connection; 31 local connection;
32 local host,user,store = module.host; 32 local host,user,store = module.host;
33 local params = module:get_option("sql"); 33 local params = module:get_option("sql");
34 34
35 local resolve_relative_path = require "core.configmanager".resolve_relative_path;
36
35 do -- process options to get a db connection 37 do -- process options to get a db connection
36 local DBI = require "DBI"; 38 local DBI = require "DBI";
37 39
38 params = params or { driver = "SQLite3", database = "prosody.sqlite" }; 40 params = params or { driver = "SQLite3" };
39 assert(params.driver and params.database, "invalid params"); 41
42 if params.driver == "SQLite3" then
43 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite");
44 end
45
46 assert(params.driver and params.database, "Both the SQL driver and the database need to be specified");
40 47
41 prosody.unlock_globals(); 48 prosody.unlock_globals();
42 local dbh, err = DBI.Connect( 49 local dbh, err = DBI.Connect(
43 params.driver, params.database, 50 params.driver, params.database,
44 params.username, params.password, 51 params.username, params.password,