tursodatabase / libsql

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

[C bindings] Have a single API function for opening all sorts of databases #1480

Open pdenapo opened 2 months ago

pdenapo commented 2 months ago

It would be nice to have an API that can open any type of connection (like you would for instace do in javascript using libsql-js) with a given URL / database location.

Futhermore, the C API seems to be no where documented. After some testing, I have found the following

1) libsql_open_ext works with

":memory:" "file:prueba.db"

2) but for a remote http connection like

"http://127.0.0.1:8080" "libsql://yourdb-username.turso.io"

you need to use libsql_open_remote. But this function does not understand the

":memory:" "file:prueba.db"

schemas.

pdenapo commented 2 months ago

You can see my test program at my libsql-C-testing repository

There I have created also a function int libsql_open_any that does exactly this. If you think that this is a good idea, I may submit a pull request. But may be this just must be the default libsql_open_remote behavoir.

(But perhaps you already have an API for doing this, I don't know)