-
Notifications
You must be signed in to change notification settings - Fork 386
feat(sql): support for SQLite pragma and encryption pragmas #2553
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
base: v2
Are you sure you want to change the base?
Conversation
- Introduced `libsqlite3-sys` dependency for SQLite support. - Updated the `load` method to accept optional pragmas for database connections. - Enhanced the JavaScript API to demonstrate loading databases with encryption keys and custom pragmas. - Added VSCode settings for Rust analyzer to enable SQLite feature, to facilitate development. - Updated Rust code to handle SQLite options and pragmas in the database connection logic.
Preload doesn't support pragma yet, because that will introduce breaking APIs here plugins-workspace/plugins/sql/src/lib.rs Line 55 in 43f0f95
If we have to support pragma in preload, then maybe something like this? {
"plugins": {
"sql": {
"preload": ["sqlite:mydatabase.db"],
"sqlite_options": {
"sqlite:mydatabase.db": {
"pragmas": {
"journal_mode": "WAL",
"foreign_keys": "ON"
}
}
}
}
}
} |
Problem fixed, the latest version supports connecting to sqlite, mysql and postgres at the same time |
I'm desperately waiting for this feature |
No one is reviewing this PR. In the meanwhile, if anyone wants to try this, you can set dependency to my branch in |
+1 on this! I am also waiting to move from my custom implementation to fully adapting to this plugin. Thanks for the PR! |
I was also using my custom implementation with cipher using rusqlite. BTW I also figured out how to use drizzle to work with this sql plugin and also rusqlite. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe out of scope of this PR, but with minimal change, it can support loading sqlite extensions.
path: string, | ||
options?: { | ||
sqlite?: { | ||
pragmas?: Record<string, string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are already adding options
. Could you add support for extensions, to fix #1705
extensions?: Record<string, Option<string>> // extension, entry_point
Sqlite::create_database(conn_url).await?; | ||
let mut sqlite_options = SqliteConnectOptions::new() | ||
.filename(filename) | ||
.create_if_missing(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Load extensions with entry points.
Had the chance to test this PR.... but I added my changes for my use: roniemartinez@7ca825d |
Hope this PR could be merged soon! |
Sorry i don't have much time for plugins at the moment and this also comes a bit in the middle of a refactor of the sql plugin (which is my bad since that should've been long done). One thing that sure would help is to do what Huakun also asked for and try this PR yourself before it's merged so we get a bit of feedback on the API and issues.
We can do it without a breaking change by creating an untagged enum for use in that Vec with string and struct variants. |
I've tried this PR and can confirm To build for Android, you need to use
It works on Android after makes such modification. Test method: pull the db file from Android device and open it in Sqlite DB Browser. |
Is it safe to put “PRAGMA key” in the config file? Putting it in the Rust code like what I did in #2553 (comment) looks a lot more safe because I can get the key dynamically from a server. |
Not reallyyy. But since we consider the js side unsafe as well a config option is not much worse than that. Assuming of course that it's not committed to git but injected at build time (true for config, js, and rust). That's a bit less obvious for the config option so maybe you're right and we shouldn't add it (yet). |
Thanks for testing :)
That's a bit problematic for those that build their apps on Windows but i guess there's no way around that. But with that both feature flags should be exposed as plugin features and users should enable what they need (making sqlcipher as a whole option again as well). |
hey everything works fine with npm run tauri dev, but I encounter issues when building a Windows package from macOS using this command
|
resolve #7
libsqlite3-sys
dependency for SQLite support.load
method to accept optional pragmas for database connections.Now sqlite encryption can be enabled like this.
I already tested on Mac, further testing needed on Windows and Linux.