Skip to content

Support read-only databases#422

Merged
ospfranco merged 3 commits into
OP-Engineering:mainfrom
powersync-community:readonly-option
Jun 26, 2026
Merged

Support read-only databases#422
ospfranco merged 3 commits into
OP-Engineering:mainfrom
powersync-community:readonly-option

Conversation

@simolus3

Copy link
Copy Markdown
Contributor

This adds a readOnly option supported by open and openAsync (both on the web and on native platforms):

  • On the web, enabling that option passes flags: 'r' to the constructor. Otherwise, we pass c (for create, write, read; the default).
  • On native platforms, this passes a readOnly flag along to sqlite3_open_v2, where we use the same logic to determine flags to include.

I have tested these changes on an iOS simulator, I didn't look into web tests.

Closes #421.

@ospfranco

ospfranco commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

You need to modify all interfaces, including the libsql ones.

There was a github macOS runner migration, please re-merge main into your branch, should fix the xcode-select error in the sqlcipher test run.

@simolus3

Copy link
Copy Markdown
Contributor Author

You need to modify all interfaces, including the libsql ones.

Unfortunately, it looks like libsql only supports passing database flags from Rust. The C bindings op-sqlite depends on don't seem to provide flags that could open read-only databases.

I have changed the implementation to throw in this case, and updated the test.

@ospfranco

Copy link
Copy Markdown
Contributor

android turso build fails

@simolus3

Copy link
Copy Markdown
Contributor Author

Can you cancel the old iOS run from the previous commit? I think it'll just timeout

@ospfranco ospfranco merged commit 3f3d28d into OP-Engineering:main Jun 26, 2026
10 checks passed
@simolus3 simolus3 deleted the readonly-option branch June 26, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Open databases as read-only

2 participants