hrana 0.4.0 copy "hrana: ^0.4.0" to clipboard
hrana: ^0.4.0 copied to clipboard

Dart client for hrana, a protocol for accessing libsql database servers.

Hrana Version

This package provides a Dart implementation for the Hrana protocol used by libsql servers to expose sqlite3 databases over web sockets.

Getting started #

To use this package, you need a server to connect to. For testing purposes, you can start an ephemeral sqld container:

docker run -p 8080:8080 -ti -e SQLD_NODE=primary ghcr.io/tursodatabase/libsql-server:latest

Usage #

With a running server, all this package needs to connect is the web socket URI and optionally a JWT token for authorization:

import 'package:hrana/hrana.dart';

void main() async {
  final database = await Database.connect(
    Uri.parse('ws://localhost:8080/'),
    jwtToken: null,
  );
  print(await database.withSession((session) async {
    await session.select('SELECT 1;');
  }));
}

In addition to web sockets, an HTTP client is available as well and selected automatically when using an http:// or https:// URL.

Additional information #

At the moment, this package implements functionality to execute statements and getting their results as rows. Batches and stored statements are supported as well, but no support for streaming cursors is implemented yet.

Contributing #

Contributions to expose more functionality of the hrana protocol are welcome!

If you need to re-run the protoc compiler, first run

$ dart pub global activate protoc_plugin

Afterwards, you can use ./proto.sh to re-generate protobuf code.

2
likes
160
pub points
28%
popularity

Publisher

verified publishersimonbinder.eu

Dart client for hrana, a protocol for accessing libsql database servers.

Repository (GitHub)
View/report issues

Topics

#database #turso #libsql #sqld #hrana

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

clock, fixnum, http, meta, pool, protobuf, sqlite3, stream_channel, web_socket_channel

More

Packages that depend on hrana