Client APIs
Usage Examples
See the example projects in the [`duckdb-dart` repository](https://github.com/TigerEyeLabs/duckdb-dart/):  
* [`cli`](https://github.com/TigerEyeLabs/duckdb-dart/tree/main/examples/cli): command-line application
* [`duckdbexplorer`](https://github.com/TigerEyeLabs/duckdb-dart/tree/main/examples/duckdbexplorer): GUI application which builds for desktop operating systems as well as Android and iOS.  
Here are some common code snippets for DuckDB.Dart:  
#### Querying an In-Memory Database {#docs:api:dart::querying-an-in-memory-database}  
```dart
import 'package:dart_duckdb/dart_duckdb.dart';

void main() {
final db = duckdb.open(":memory:");
final connection = duckdb.connect(db);

connection.execute('''
CREATE TABLE users (id INTEGER, name VARCHAR, age INTEGER);
INSERT INTO users VALUES (1, 'Alice', 30), (2, 'Bob', 25);
''');

final result = connection.query("SELECT * FROM users WHERE age > 28").fetchAll();

for (final row in result) {
print(row);
}

connection.dispose();
db.dispose();
}
```  
#### Queries on Background Isolates {#docs:api:dart::queries-on-background-isolates}  
```dart
import 'package:dart_duckdb/dart_duckdb.dart';

void main() {
final db = duckdb.open(":memory:");
final connection = duckdb.connect(db);

await Isolate.spawn(backgroundTask, db.transferrable);

connection.dispose();
db.dispose();
}

void backgroundTask(TransferableDatabase transferableDb) {
final connection = duckdb.connectWithTransferred(transferableDb);
// Access database ...
// fetch is needed to send the data back to the main isolate
}
```