D
Deno

help

Turso with local db file

TTino10/13/2023
I wanted to try out Turso's syncURL feature and for that it creates a local db file to read from and syncs any written data remote first before it writes it locally. However, I am not getting that far due to the following issue: LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls Deno code:
// main.ts
createClient({
url: "file:local.db",
syncUrl: Deno.env.get("URL"),
authToken: Deno.env.get("TOKEN")
});
// main.ts
createClient({
url: "file:local.db",
syncUrl: Deno.env.get("URL"),
authToken: Deno.env.get("TOKEN")
});
The script has all permissions by deno run -A main.ts. Based on the error file: is simply not supported since Deno is allowing only web standard APIs? Any other way to allow this? I am just suprised this isn't working since the use case seems acceptable.
DAHDeno AI Helper10/13/2023
Based on the documentation, Deno supports fetching file: URLs as of Deno 1.16. However, it only supports absolute file URLs, which means that fetch("./some.json") will not work. If you want to fetch some resource relative to the current module, you would want to use import.meta.url as the base. Here's an example from the documentation:
const response = await fetch(new URL("./config.json", import.meta.url));
const config = await response.json();
const response = await fetch(new URL("./config.json", import.meta.url));
const config = await response.json();
However, it's important to note that permissions are applied to reading resources, so an appropriate --allow-read permission is needed to be able to read a local file. Fetching locally only supports the GET method, and will reject the promise with any other method. A file that does not exist simply rejects the promise with a vague TypeError. In your case, it seems like the file: URL is not supported by the libsql client you're using. This is not a limitation of Deno itself, but rather the specific library. You might want to check the library's documentation or reach out to its maintainers for more information on how to use local files with it. 🦕
TTino10/14/2023
if I run this with bun all works just fine. So it seems that the issue is not libsql but Deno or do I miss anything?
TTino10/14/2023
the error message reads: error: Uncaught LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls
GitHub
GitHub - libsql/libsql-client-ts: TypeScript/JavaScript client API ...
TypeScript/JavaScript client API for libSQL. Contribute to libsql/libsql-client-ts development by creating an account on GitHub.
TTino10/14/2023
and I guess with "client" it means Deno
TTino10/14/2023
GitHub
Deno compatible local client · Issue #67 · libsql/libsql-client-ts
Hey I was very interested in learning how to use Turso on my most recent Deno project. I resorted to making a Deno compatible client for local development as Deno only had support for the web versi...

Looking for more? Join the community!

Recommended Posts
Importing local NodeJS module from DenoIs it possible to import a javascript file that has `node` imports for standart modules like `http` how I can install antd in my deno project?how I can install antd in my deno project?Deno Fresh Twind ColorsJust a message to anyone using Deno Fresh and wondering why their tailwindcss colors aren't working-Can you run Deno.serve in a pooled thread mode?is there a way in Deno to run a http request in a separate thread?How do I rerender my island after a signal change?Hi there im trying to rerender this sidebar navigation when you toggle it, making it change size and'Relative import path not prefixed' error from @types/express .d.ts file?Converting an express mjs project to deno & TS, and running into an issue using code from this exampThe requested module 'test/jsx-runtime' does not provide an export named 'jsxs'hej, I have a exported function `jsx()` stored in `jsx-runtime.ts`. I also added these `deno.json` scompiled artifact can't find deno.jsonI'm using github actions to build and publish a binary like so ``` DENO_TLS_CA_STORE=system deno comysql query is skippedHi, I have a function that should retrieve data from the database and then process and return it. ThUsing in-memory KV (sqlite) in productionIs it ok to use the KV backed by a local SQLite database in production ? If not, could you explain wdeno.land servers not reachable / timeoutFor the past few days, I've been encountering timeouts when trying to load modules from deno.land/x.I want to install styledComponents in my deno projectsomeone could help me?: deno run -A npm:styled-components -i error: package 'styled-components' did