Live data from Hacker News

Show HN: Bi-directional sync between Postgres and SQLite

powersync.com

1–10 of 107 posts

Show HN: Bi-directional sync between Postgres and SQLite

#1
Hi HN,

Today we’re launching PowerSync, a PostgresSQLite bi-directional sync engine that enables an offline-first app architecture. It currently supports Flutter, React Native and web (JavaScript) using Wasm SQLite in the browser, with more client SDKs on the way.

Conrad and I (Ralf) have been working on our sync engine since 2009, originally as part of a full-stack app platform. That version of the system is still used in production worldwide and we’ve learnt a lot from its use cases and scaling. About a year ago we started on spinning off PowerSync as a standalone product that is designed to be stack-agnostic.

If you’d like to see a simple demo, check out the pebbles widget on the landing page here: https://www.powersync.com/

We wrote about our architecture and design philosophy here: https://www.powersync.com/blog/introducing-powersync-v1-0-po...

This covers amongst other things how we designed the system for scalable dynamic partial replication, why we use a server authority architecture based on an event log instead of CRDTs for merging changes, and the approach to consistency.

Our docs can be found here: https://docs.powersync.com/

We would love to hear your feedback! - Ralf, Conrad, Kobie, Phillip and team

Show HN: Bi-directional sync between Postgres and SQLite
powersync.com

Re: Show HN: Bi-directional sync between Postgres and SQLite

#4
post #2

I dig it, super cool idea! What about timestamps, though? SQLite doesn't support them.. does it end up being restricted to the lowest common denominator between the two databases in terms of supported types/functionality?

SQLite has a number of functions to work with time but the underlying storage format is just going to be--depending on what precision/range of timestamp you want--a float or an integer... to the extent, of course, that SQLite has types at all (as it frankly doesn't, thereby making this question kind of moot).

Re: Show HN: Bi-directional sync between Postgres and SQLite

#5
post #4
post #2

I dig it, super cool idea! What about timestamps, though? SQLite doesn't support them.. does it end up being restricted to the lowest common denominator between the two databases in terms of supported types/functionality?

SQLite has a number of functions to work with time but the underlying storage format is just going to be--depending on what precision/range of timestamp you want--a float or an integer... to the extent, of course, that SQLite has types at all (as it frankly doesn't, thereby making this question kind of moot).

SQLite has five types, documented here: https://www.sqlite.org/datatype3.html

    null, integer, real, text, blob
It has a historically cavalier attitude to enforcing them (which I believe it inherited from TCL) but that changed in November 2021 with the release of strict table mode in version 3.37.0: https://www.sqlite.org/stricttables.html

Re: Show HN: Bi-directional sync between Postgres and SQLite

#6
post #2

I dig it, super cool idea! What about timestamps, though? SQLite doesn't support them.. does it end up being restricted to the lowest common denominator between the two databases in terms of supported types/functionality?

Co-founder (Conrad) here. SQLite does indeed have a narrow set of types. Timestamps in Postgres are converted to text in SQLite in a format that is compatible with ISO8601 and SQLite's functions. Type conversions are documented here: https://docs.powersync.com/usage/sync-rules/types

Re: Show HN: Bi-directional sync between Postgres and SQLite

#7

Possible integration with drizzle orm ? Let me define schema with drizzle and use its generated objects to interact with db. Postgres driver for server SQLite driver for client

It is on our near-term roadmap to support ORMs for the client-side SQLite database. Our goal with ORMs is to fit in with existing popular libraries on each platform (e.g. Flutter, React Native, etc.), rather than creating a PowerSync-specific ORM over all platforms. Drizzle is one of the integrations that we're looking at, along with Prisma and others.

Re: Show HN: Bi-directional sync between Postgres and SQLite

#8
Sorry, unfortunately I am a bit lost on what this does (on my phone, so couldn't see the demos on the website). I'm an android developer, but I am not sure what this would do. Do you have an example of an app/backend at which you can explain where Powersync helps?

Re: Show HN: Bi-directional sync between Postgres and SQLite

#10

Sorry, unfortunately I am a bit lost on what this does (on my phone, so couldn't see the demos on the website). I'm an android developer, but I am not sure what this would do. Do you have an example of an app/backend at which you can explain where Powersync helps?

The goal is basically to help you build offline-first apps. In the offline-first paradigm, app code works directly with a client-side embedded database, which automatically syncs with a backend database in the background. This is in contrast to cloud-first apps which primarily use a cloud datastore via APIs.

Working with a local database (e.g. SQLite) means that apps feel instant to use because of low latency, and remain functional when the user’s network connection is unreliable or offline. Also, offline-first typically offers built-in real-time collaboration by automatically syncing data in the background.

There's 1-minute demo video here of a Flutter "To-Do List" app showing some of these concepts: https://www.youtube.com/watch?v=VTx5ViRe3HY (this demo uses a Supabase Postgres backend for simplicity)

Post reply on HN