aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--util/sql.lua6
-rw-r--r--util/sqlite3.lua6
3 files changed, 13 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index c7c7e9c9..3e1772e1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -46,6 +46,7 @@ TRUNK
- New 'keyval+' combined keyval/map store type
- Performance improvements in internal archive stores
- Ability to use SQLite3 storage using LuaSQLite3 instead of LuaDBI
+- SQLCipher support
### Module API
diff --git a/util/sql.lua b/util/sql.lua
index c897d734..2f0ec493 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -84,6 +84,12 @@ function engine:connect()
dbh:autocommit(false); -- don't commit automatically
self.conn = dbh;
self.prepared = {};
+ if params.password then
+ local ok, err = self:execute(("PRAGMA key='%s'"):format(dbh:quote(params.password)));
+ if not ok then
+ return ok, err;
+ end
+ end
local ok, err = self:set_encoding();
if not ok then
return ok, err;
diff --git a/util/sqlite3.lua b/util/sqlite3.lua
index 470eb46d..fec2d162 100644
--- a/util/sqlite3.lua
+++ b/util/sqlite3.lua
@@ -114,6 +114,12 @@ function engine:connect()
if not dbh then return nil, err; end
self.conn = dbh;
self.prepared = {};
+ if params.password then
+ local ok, err = self:execute(("PRAGMA key='%s'"):format((params.password:gsub("'", "''"))));
+ if not ok then
+ return ok, err;
+ end
+ end
local ok, err = self:set_encoding();
if not ok then
return ok, err;