comparison util/sql.lua @ 13715:edd006093533 13.0

util.sql: Don't send SQLCipher key to Postgres or MySQL (thanks gllmhyt) This was copied from util.sqlite3 which only deals with SQLite3, but here Postgres or MySQL are also possibilities, which wouldn't support this.
author Kim Alvefur <zash@zash.se>
date Sun, 16 Feb 2025 11:52:07 +0100
parents 844e7bf7b48a
children e7c52d0b0e0d
comparison
equal deleted inserted replaced
13713:4a687745bb51 13715:edd006093533
82 if not ok then return ok, dbh; end 82 if not ok then return ok, dbh; end
83 if not dbh then return nil, err; end 83 if not dbh then return nil, err; end
84 dbh:autocommit(false); -- don't commit automatically 84 dbh:autocommit(false); -- don't commit automatically
85 self.conn = dbh; 85 self.conn = dbh;
86 self.prepared = {}; 86 self.prepared = {};
87 if params.password then 87 if params.driver == "SQLite3" and params.password then
88 local ok, err = self:execute(("PRAGMA key='%s'"):format(dbh:quote(params.password))); 88 local ok, err = self:execute(("PRAGMA key='%s'"):format(dbh:quote(params.password)));
89 if not ok then 89 if not ok then
90 return ok, err; 90 return ok, err;
91 end 91 end
92 end 92 end