Skip to content

Use androidx sqlite bindings internally #230

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Jul 25, 2025

This restructures our internal driver implementations to be aligned with cross-platform APIs from the androidx.sqlite:sqlite library, and removes all internal usages of SQLiter, SQLDelight and sqlite-jdbc:

  • The :persistence project has been removed.
  • The :dialect project has been removed.
  • The :static-sqlite-driver project has been removed.

As a replacement, this adds the experimental SQLiteConnectionPool API in :core. That API has been designed to:

  • express the assumption that the PowerSync SDK will be implemented ontop of a connection pool.
  • make it easy to implement with our existing connection pool implementation.
  • be a direct and low-level wrapper around SQLite connections (allowing our existing APIs to be implemented as wrappers).
  • allow implementations based on Room and GRDB connection pools (the read() and write() methods correspond to useConnection in Room, see the Transactor API from Room for a comparison).

Since pools can now be implemented externally, there's a new (also marked as experimental) PowerSyncDatabase.opened method to open a PowerSync database ontop of those pools. The internal opening logic has also been refactored to call that method.

Since we're now using a BundledSQLiteDriver from androidx.sqlite, the platform-specific parts of the opening factory are greatly reduced. The only remaining platform-specific parts relate to loading the PowerSync core extension and finding a suitable default directory. The rest is now based in common.

In :core, the public interfaces like the cursor are then consistently implemented across the common underlying connection pool API.

I've also added a new API to PowerSyncDatabase to give out a temporary view to an underlying SQLiteConnection. This would give users full control over the statements to run, while still letting the PowerSync SDK taking care of connection management.

TODOs:

  • Check Swift SDK still works with this.
  • Check we're using the same paths as SQLiter by default

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.

1 participant