tauri-apps / tauri-apps/plugins-workspace

[feqture request] sql: Support loading databases from bundled resources

Open
#1,155 0 comments 0 reactions 0 assignees View on GitHub
plugin: sql type: feature request
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

## Why

Uses of SQLite can be categorized into two ways: reading and writing complex application state, and reading from an existing dataset. AFAIK this is *OLTP* and *OLAP*, respectively.

For complex state, it is appropriate for the file to be created and managed in appDataDir. However, for the case where the developer is bringing existing data to query (and only needs read-only access), it should be possible to access a database file as [a resource](https://tauri.app/v1/guides/building/resources) directly. Right now, plugin-sql does not allow this.

(This situation happens in other frameworks as well, where the sqlite adapter does not provide read-only access to bundled databases. The common, and I'd argue ugly, work around is to copy the bundled database to appDataDir's equivalents, doubling the storage use for no good reason.)

## TL;DR and proposed solution

It would be nice if plugin-sql provides read-only access to sqlite databases bundled as resources. This can be done, perhaps, by having [plugin.rs recognize a different type](https://github.com/tauri-apps/tauri-plugin-sql/blob/v2/src/plugin.rs#L157), perhaps `sqlite-resource:`, where `path` is resolved as a resource and errors if it doesn't exist.

This should not have safety implications, I think, as it only allows the developer to decide to access bundled resources.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.