<rss version="2.0">
  <channel>
    <title>Meet Gor - Tag: libsql</title>
    <link>https://www.meetgor.com</link>
    <description>Posts tagged with libsql</description>
    <language>en-us</language>
    <pubDate>Sat, 09 May 2026 05:38:52 UTC</pubDate>
    <item>
      <title>LibSQL: Query a remote Turso database with cURL</title>
      <link>https://www.meetgor.com/til/libsql-query-remote-db</link>
      <description>Querying a libsql database hosted on turso with cURL. Using a remote sqlite-like db with turso api to query data.</description>
      <pubDate>Wed, 15 Nov 2023 00:00:00 UTC</pubDate>
      <content>If you are using a local [libsql](https://turso.tech/libsql) database, it is quite easy to query the database, but for a remote or a database on a hosted cloud platform like [turso](https://turso.tech/), we can use other clients or the api itself to query the data.&#xA;&#xA;We can use the turso cli to get the authentication token for the database and then query the database.&#xA;&#xA;## Turso CLI&#xA;&#xA;Using the [turso-cli](https://docs.turso.tech/reference/turso-cli) to access the turso platform. We will use turso cli to create a libsql database, create authentication tokens, and query the db.&#xA;&#xA;### Create a database (it&#39;s optional, you might already have a database)&#xA;&#xA;```bash&#xA;turso db create&#xA;```&#xA;&#xA;You will get a database on the turso cloud platform with some random interesting name like a passphrase.&#xA;&#xA;Use the command `turso db list` and copy the URL&#xA;&#xA;```graphql&#xA;DB_URL=dbname-orgname.turso.io&#xA;```&#xA;&#xA;### Create an authentication token for a particular database&#xA;&#xA;```bash&#xA;turso db tokens create db_name&#xA;```&#xA;&#xA;Copy the JWT token and this will be used as a authentication token when accessing the remote database in the turso cloud.&#xA;&#xA;```bash&#xA;TOKEN=abcdef.12345.wxyz&#xA;DB_URL=dbname-orgname.turso.io&#xA;```&#xA;&#xA;* Querying the database using curl or other [api clients](https://docs.turso.tech/libsql/client-access)&#xA;    &#xA;&#xA;```bash&#xA;curl -s -H &#34;Authorization: bearer $TOKEN&#34; \&#xA;     -d &#39;{&#34;statements&#34;: [&#34;SELECT name FROM sqlite_master WHERE type=\&#34;table\&#34;;&#34;]}&#39; \&#xA;     $DB_URL&#xA;```&#xA;&#xA;We can use `curl` or any api client tools to send queries to the database hosted on the turso platform. We need to provide the JWT token in the `Authorization` header to connect to that particular database. The request&#39;s body is a JSON string with a list of statements to query the database.&#xA;&#xA;```graphql&#xA;[&#xA;    {&#xA;        &#34;results&#34;:&#xA;            {&#xA;                &#34;columns&#34;: [&#34;name&#34;],&#xA;                &#34;rows&#34;:[&#xA;                    [&#34;libsql_wasm_func_table&#34;], [&#34;_litestream_seq&#34;], [&#34;_litestream_lock&#34;], [&#34;sqlite_sequence&#34;], [&#34;user&#34;]&#xA;                ]&#xA;            }&#xA;     }&#xA;]&#xA;```&#xA;&#xA;The result is a list of key-value pairs as `columns` and `rows` for each of the statements in the body. The columns are a list of column names requested in the query, and the rows are a list of rows where each row is a list of field values from the query.</content>
      <type>til</type>
    </item>
  </channel>
</rss>