Benjamin-Philip

Benjamin-Philip

Announcing Turxo! Turxo is a library (hex, git repo) for bindings to the Turso database, a SQLite compatible in-process database written in Rust. It has a number of new features over SQLite like multi-version concurrency control (MVCC), io_uring backed async I/O, edge replication, vector support and more. Turxo is the first step towards bringing these improvements to the Elixir ecosystem.

As of now we support the following operations:

  • Open or create a Turso database, including in-memory databases
  • Connect to an open database
  • Execute SQL commands or perform queries on a connection
  • Prepare reusable SQL statements, then execute or query them

Here’s a rough example copied from the README:

alias Turxo.NIF.Wrapped, as: Turso

# Open an in-memory database
{:ok, db} = Turso.db_open(":memory:")

# Establish a connection
{:ok, conn} = Turso.db_connect(db)

# Execute SQL (no parameters)
{:ok, 0} =
  Turso.conn_execute(
    conn,
    "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)",
    []
  )

# Insert using positional parameters
{:ok, 1} =
  Turso.conn_execute(conn, "INSERT INTO users (name, email) VALUES (?1, ?2)", [
    "alice",
    "alice@example.com"
  ])

# Query with positional parameters
{:ok, [["alice@example.com"]]} =
  Turso.conn_query(conn, "SELECT email FROM users WHERE name = (?1)", ["alice"])

# Prepare a statement
{:ok, stmt} =
  Turso.conn_prepare(conn, "INSERT INTO users (name, email) VALUES (:name, :email)", false)

# Execute the prepared statement with named parameters
{:ok, 1} = Turso.stmt_execute(stmt, name: "bob", email: "bob@example.com")

# Query with named parameters
{:ok, [["bob@example.com"]]} =
  Turso.conn_query(conn, "SELECT email FROM users WHERE name = (:name)", name: "bob")

# Prepare a statement for querying
{:ok, qstmt} = Turso.conn_prepare(conn, "SELECT id, name FROM users", false)
{:ok, rows} = Turso.stmt_query(qstmt, [])
# rows = [[1, "alice"], [2, "bob"]]

As you can see, the Turxo v0.1.0 release is at a very early state with only the raw Rust bindings and lacking in docs. I decided to release it nonetheless to make it available to the public for feedback. Here are the immediate features I have on the Roadmap (PRs welcome!):

  • Transactions
  • DBConnection integration
  • Pragmas

Particularly, I would appreciate any help in overhauling my test suite to something more robust and comprehensive than the handwritten example-like test I have now.

I also plan to write Ecto and Ash adapters in separate repositories.

Let me know any feedback you may have.

Showing Posts 1 to 7

glauber

glauber

Hello! This is really good. I am the creator of Turso

Any reason why you wouldn’t submit this to the Turso tree? We’ve been keeping the bindings in tree, and that helps a lot with regression tests, making sure features are added to new drivers, etc.

Benjamin-Philip

Benjamin-Philip OP

Hi Glauber, welcome to Elixirforum!

When I started the project, I didn’t think about it too deeply. Culturally in the Erlang/Elixir ecosystem, we tend to keep bindings/implementations within the Elixir community. In the case of databases, almost none of the database drivers (see the Ecto project) have been upstreamed. There’s a similar pattern with message queue adapters (see the Broadway project), gRPC, Protobuf and even generally in smaller libraries. I’m not sure why this is the accepted practice, but my decision to build outside of the Turso tree is very much just me following established norms. Though, recently I have been trying to change this with my work upstreaming the Erlang implementation of Apache Arrow to the ASF.

However, I’m happy to upstream this to Turso if you’re interested. I think that first party status is generally better for the quality and health of the project.

My original motivations for writing this library do partially clash with upstreaming though. As a young student, I approached this as a learning exercise, not because I needed to use Turso, whilst still addressing a genuine gap in the community. The learning was partially technical, but my primary motivation was to learn what was involved in being a maintainer. Things like:

  • Release processes
  • Handling issues and PRs
  • Maintaining code quality in contributions
  • Growing a userbase as well as contributors

My thought was building something production-grade myself would expose me to these responsibilities. My worry with upstreaming is that I would learn less about maintenance since most of the load would be handled by the Turso team.

That said, I still think upstreaming is what’s best for the library. Maybe if we can come to some understanding over the level of oversight I would have if I were to upstream, perhaps we can work something out.

You’ve clearly not looked at the code. I personally don’t consider it release worthy as-is, and I am quite disgusted with myself over the lack of documentation. It was only after my dad convinced me that a release was more meaningful and useful than a lone git repo, that I released a v0.1.0.

taro

taro

Lovely name. Thank you for the initiative. I’m sitting on libSQL until something matures for Turso; can’t wait for v1.0. It’s worth mentioning ex_turso and turso_ex here since it seems they are not posted in this forum.

dimitarvp

dimitarvp

I am super close to officially releasing and announcing Xqlite — Xqlite v0.10.0 and now I wonder whether we should join forces and have one adapter that can “quack” multiple breeds of SQLite3. Had my eye on Turso for a long time and almost lost hope they’ll come through. Thanks for the confirmation, @glauber!

glauber

glauber

@Benjamin-Philip your father is right! ship early, ship, ship, ship! Tell the man I sent my regards, and wild to see you already doing this at high school age. My oldest is 7 and I wish he follows your path.

You are right that I didn’t look at the code. When I said it is very good, I was referring to the fact it exists.

To both you and @dimitarvp : First, thanks for the warm welcome in this community! We at Turso want to make sure Turso integrates well with as many ecosystems as possible. In no way you are required to send the code back to Turso, but we do want to make it clear that if you want to, the door is open. We have found a lot of success with drivers in tree, because we can then integrate with our CI and make sure new released don’t break it. But that’s not always possible. For go for instance, it’s a bit weird because Go uses git trees as import paths, and putting everything in the same tree causes friction.

One model that I think works well is if you bring the core driver into Turso, but for higher level adapters like native ORMs you keep it outside.

It truly is whatever works best for you and your community! We’re here to help.

Benjamin-Philip

Benjamin-Philip OP

This sounds like the way to go. Maintaining the ORM adapter out of tree addresses my learning goals. Since I started the project out of tree, I’ll smoothen the rough edges over a couple of releases myself, and later submit a more complete version to the tree.

DVS_Labs

DVS_Labs

There’s also EctoLibSql based on libSQL. Slightly different to targeting Turso but could still be interesting to some.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews