sqlite3 1.5.1 copy "sqlite3: ^1.5.1" to clipboard
sqlite3: ^1.5.1 copied to clipboard

outdated

Provides lightweight yet convenient bindings to SQLite by using dart:ffi

sqlite3 #

Provides Dart bindings to SQLite via dart:ffi.

For an example on how to use this library from Dart, see the example.

Supported platforms #

You can use this library on any platform where you can obtain a DynamicLibrary of sqlite.

Here's how to use this library on the most popular platforms:

  • Android: Flutter users can depend on the sqlite3_flutter_libs package to ship the latest sqlite3 version with their app
  • iOS: Contains a built-in version of sqlite that this package will use by default. When using Flutter, you can also depend on sqlite3_flutter_libs to ship the latest sqlite3 version with your app.
  • Linux: You need to install an additional package (like libsqlite3-dev on Debian), or you manually ship sqlite3 with your app (see below)
  • macOS: Contains a built-in version of sqlite that this package will use by default. Also, you can depend on sqlite3_flutter_libs if you want to include the latest sqlite3 version with your app.
  • Windows: You need to manually ship sqlite3 with your app (see below)

On Android, iOS and macOS, you can depend on the sqlcipher_flutter_libs package to use SQLCipher instead of SQLite. Just be sure to never depend on both sqlcipher_flutter_libs and sqlite3_flutter_libs!

Manually providing sqlite3 libraries #

Instead of using the sqlite3 library from the OS, you can also ship a custom sqlite3 library along with your app. You can override the way this package looks for sqlite3 to instead use your custom library. For instance, if you release your own sqlite3.so next to your application, you could use:

import 'dart:ffi';
import 'dart:io';

import 'package:sqlite3/open.dart';
import 'package:sqlite3/sqlite3.dart';

void main() {
  open.overrideFor(OperatingSystem.linux, _openOnLinux);

  final db = sqlite3.openInMemory();
  // Use the database
  db.dispose();
}

DynamicLibrary _openOnLinux() {
  final scriptDir = File(Platform.script.toFilePath()).parent;
  final libraryNextToScript = File('${scriptDir.path}/sqlite3.so');
  return DynamicLibrary.open(libraryNextToScript.path);
}

Just be sure to first override the behavior and then use sqlite3.

Supported datatypes #

When binding parameters to queries, the supported types are ìnt, double, String, List<int> (for BLOB) and null. Result sets will use the same set of types.

292
likes
0
pub points
97%
popularity

Publisher

verified publishersimonbinder.eu

Provides lightweight yet convenient bindings to SQLite by using dart:ffi

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection, ffi, meta

More

Packages that depend on sqlite3