-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hidden early PRAGMAs prevent using SQLCipher #621
Comments
Specifying journal_mode Delete on SqliteConnectOptions resolved the issue. |
Creating a database can be resolved by specifying journal_mode Delete on SqliteConnectOptions, |
SQLx's SQLite support depends on libsqlite3-sys which also supports SQLCipher in addition to SQLite.
in your application's Cargo.toml, SQLx will use SQLCipher via libsqlite3-sys. SQLCipher source code is not bundled with libsqlite3-sys. In replacement, a SQLCipher built from its source code retrieved from GitHub can be used with SQLx.
Note, if you omit SQLITE_ENABLE_COLUMN_METADATA, SQLx complains again that symbol sqlite3_column_origin_name is undefined.
To test disabling SQLx's hidden early PRAGMAs, modify connect function in sqlx-core/src/sqlite/options/connect.rs commenting out not to execute PRAGMAs. fn connect(&self) -> BoxFuture<'_, Result<Self::Connection, Error>>
where
Self::Connection: Sized,
{
Box::pin(async move {
let mut conn = establish(self).await?;
/*
// send an initial sql statement comprised of options
let init = format!(
"PRAGMA journal_mode = {}; PRAGMA foreign_keys = {};",
self.journal_mode.as_str(),
if self.foreign_keys { "ON" } else { "OFF" }
);
conn.execute(&*init).await?;
*/
Ok(conn)
}) In your application issue "PRAGMA key = 'passphrase'" as the first command after connection, and encryption works. |
BTW, Diesel allows you to implement the CustomizeConnection, and then hook that into the Builder.something like that would be very useful for SQLx as well |
Closed by #1295 |
In order to use encryption with SQLCipher,
it is required to issue "PRAGMA key = 'passphrase'" as the first command
just after connected.
But, current implementation of SQLx always issues
"PRAGMA journal_mode = {}; PRAGMA foreign_keys = {};"
just after connected before any user's command issued.
That prevents using SQLx with SQLCipher.
The text was updated successfully, but these errors were encountered: