tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
9.55k stars 252 forks source link

Cloudflare Worker issue #1372

Open spigaz opened 4 months ago

spigaz commented 4 months ago

Hi, how is it possible to use turso from a worker?

You have the "cloudflare" flag for it.

But the only methods to create a remote connection, that I believe its what I have to use, force me to enable the remote flag, once I do, I always end up with the mio dependency activated.

And AFAIK there is no way to compile mio to wasm just yet.

Is there some other way to establish a connection, some alternative method?

I have found this ts example... https://github.com/tursodatabase/examples/blob/master/app-workers-turso-ts-demo/src/index.ts

Thank you!

flexchar commented 2 months ago

I've been using with no problem for long time. It is important that you use client for the edge runtime as shown here: https://docs.turso.tech/sdk/ts/quickstart

import { createClient } from "@libsql/client/web";

export const turso = createClient({
  url: process.env.TURSO_DATABASE_URL,
  authToken: process.env.TURSO_AUTH_TOKEN,
});
spigaz commented 2 months ago

@flexchar My point was using it from rust, but I was able to use it using the deprecated libsql-client-rs https://github.com/tursodatabase/libsql-client-rs?tab=readme-ov-file#cloudflare-workers

I even ported the axum example to use it https://github.com/spigaz/workers-rs-axum-tursodb

Yes, the libsql-client-rs API is a bit old.

aviplayer commented 5 days ago

I tried to integrate, but mentioned issue still exists. Looks like this is still an issue to use Turso from CloudFlare Rust. Any eta on this Bug? Formally feature exists, but it doesn't work/compile