tursodatabase / libsql

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

How to enable the `attach` permission for databases #1634

Closed ptrxyz closed 1 month ago

ptrxyz commented 1 month ago

I am playing around with a local installation of sqld in a docker container and I wonder how I can enable the attach permissions for a database.

Currently I am running

$ docker run -p8080:8080 -p8000:8000 --rm ghcr.io/tursodatabase/libsql-server sqld --enable-http-console --enable-namespaces  --http-listen-addr=0.0.0.0:8080 --admin-listen-addr=0.0.0.0:8000

and setup a few namespaces

$ curl -H "Content-Type: application/json" --data '{}' -X POST http://localhost:8000/v1/namespaces/db1/create
$ curl -H "Content-Type: application/json" --data '{}' -X POST http://localhost:8000/v1/namespaces/db2/create

This works so far, I can connect to my namespaces with the turso CLI

$ turso db shell 'http://db1.localhost:8080
Connected to http://db1.localhost:8080

Welcome to Turso SQL shell!

Type ".quit" to exit the shell and ".help" to list all available commands.
...

Yet I do not manage to enable the attach permissions. The only documented way to do this I found was using the turso CLI: turso db config attach <database name>, yet I don't get this to work:

$ turso db config attach allow 'http://db1.localhost:8080'
Error: database http://db1.localhost:8080 not found. List known databases using turso db list

And turso db list command won't do anything either since I am in a self-hosted environment. So can anyone clarify this? I am a bit lost.

haaawk commented 1 month ago

turso db config attach allow works only with databases hosted on Turso platform. If you need help with using libsql locally please join our Discord server and ask for help there https://discord.gg/turso.