libsql_dart 0.0.3 copy "libsql_dart: ^0.0.3" to clipboard
libsql_dart: ^0.0.3 copied to clipboard

LibSQL Dart client library to interact with LibSQL/Turso database instance.

libsql_dart #

LibSQL Dart client library to interact with LibSQL/Turso database instance.

Supported Features #

Currently, only embedded replica is supported, others will follow.

Getting Started #

  • Add it to your pubspec.yaml.
  libsql_dart: 0.0.1
  • Call LibsqlClient.init
  await LibsqlClient.init();
  • Instantiate the client
  final client = LibsqlClient(
      replicaPath: path,
      syncUrl: '<TURSO_OR_LIBSQL_URL>',
      syncToken: '<TOKEN>',
      syncIntervalMilliseconds: 5000);
  await client.create();
  • Call sync if necessary
  await client.sync();
  • Read the locally replicated db using sqflite
  final db = await openDatabase(path, readOnly: true);
  final result = await db.rawQuery('select * from customers');
  print(result);

Note Code snippets above also use path_provider and sqflite packages. When using other sqlite libraries to read the file, you need to make sure that it is done in read only mode, because the replication process assumes exclusive write lock over the file.

8
likes
0
pub points
57%
popularity

Publisher

verified publisherandikatanuwijaya.dev

LibSQL Dart client library to interact with LibSQL/Turso database instance.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_rust_bridge, plugin_platform_interface

More

Packages that depend on libsql_dart