elixir-sqlite / exqlite

An SQLite3 driver for Elixir
https://hexdocs.pm/exqlite
MIT License
208 stars 47 forks source link

libSQL support/fork #261

Closed lessless closed 1 month ago

lessless commented 11 months ago

Hey folks,

I can see increased interest in SQLite in my tech bubble.

Ahd that's how I learned about libSQL which offers several improvements including altering columns.

One of the project goals is to maintain 100% backwards compatibility with SQLite yet it still may deserve fork/another project, and I appreciate that it might be beyond the resources that the team currently have.

This also made me think that Exqlite may benefit from swappable backends.

update: I played a bit with libSQL and Exqlite and it seems that libSQL is a Rust project and doing it right means taking completely another route of building native extension against it with Rustler.

that followed a brief chat in Turso's Discord in the context of an already ongoing conversation which highlighted the exciting capability of embedded replications, which is definitely beyond the original SQLite scope.

Thanks! Embedded replicas require not only that the driver will use libsql instead of sqlite (which is very easy) but also that our http and sync functions are exposed (should be also easy if adopting libsql happened throughtl the rust library, not C).

Unfortunately we also don't have the bandwidth to support elixir at the moment, but if the driver maintainers want to do that, we would be happy to help!

Best, Yevhenii

warmwaffles commented 11 months ago

So I designed ecto_sqlite3 to have the ability to swap out different sqlite backend implementations. All you need to do honestly is build a new library that implements the db_connection interface. I believe this is how you can swap it out easily.

This would allow you to bring in your own rustler compilation process.

Some big things to consider about libsql, if at any point they diverge on the features of the SQL syntax and what is available (native json operators like psql, ltree, etc...) then we will not be able to support that with the ecto_sqlite3 implementation.

jeregrine commented 11 months ago

I dropped in a binary of libsql into ecto_sql and it just worked so its probably not that hard if you need this to work, fork exqlite and add the libsql amalgamation and you are good.

lessless commented 11 months ago

@jeregrine, thanks; I'll check that out. I remember having trouble building it, but I will give it another try. It brings ability to alter tables which is very worth the pursuit https://github.com/tursodatabase/libsql/blob/main/libsql-sqlite3/doc/libsql_extensions.md#altering-columns

jeregrine commented 11 months ago

I just needed to bring in libsql-amalgamation-0.2.2.tar.gz in place of sqlite3.h/cc and it "just worked". I'm not sure ecto_sqlite supports alter but nothing stops you from using it manually.

warmwaffles commented 11 months ago

That is correct, ecto_sqlite does not support alter because well, sqlite doesn't support alter 😉