stoolap_flutter 0.2.0
stoolap_flutter: ^0.2.0 copied to clipboard
High-performance, pure Rust embedded SQL database for Flutter with native Vector Search, MVCC transactions, and reactive Streams.
Stoolap Flutter SDK #
The high-performance SQL database that ships with your app.
Stoolap is a high-performance, embedded SQL database written entirely in Rust. It brings enterprise-grade features like MVCC transactions, parallel execution, and native vector search directly to your Flutter applications.
Official Reference: https://stoolap.io/
Features 📦 #
- 🦀 Pure Rust Core: Memory-safe and lightning-fast database engine.
- 🔍 Native Vector Search:
VECTORtype and HNSW indexes for sub-linear semantic search. - ⚡ Parallel Execution: Automatically parallelizes joins, sorts, and aggregations across all CPU cores.
- 🛡️ MVCC Transactions: Full ACID compliance with snapshot isolation. Readers never block writers.
- 🕰️ Time-Travel Queries: Query your data exactly as it existed in the past using the
AS OFsyntax. - 🔄 Reactive API: Built-in support for "Live Queries" using Dart Streams.
- 🏗️ Advanced SQL: Supports CTEs (including Recursive), Window Functions, and standard SQL joins.
- 📱 Mobile Optimized: Optimized with SIMD for ARM64 (M1/M2 and modern Android chips).
Quick Start 🚀 #
It's super easy to get started. You just need to initialize Stoolap and open your database.
1. Installation #
Add stoolap_flutter to your pubspec.yaml:
dependencies:
stoolap_flutter: ^0.2.0
2. Initialization #
Initialize the native Rust bridge in your main() function:
import 'package:stoolap_flutter/stoolap_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize the native Rust library
await StoolapDatabase.init();
runApp(const MyApp());
}
3. Basic Usage #
final db = StoolapDatabase();
await db.open('my_app_data.db');
// Execute a command
await db.execute('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
// Insert with parameters
await db.execute('INSERT INTO users (name) VALUES (?)', params: ['Alice']);
// Query results
final rows = await db.query('SELECT * FROM users');
for (var row in rows) {
print('User: ${row.values[1]}'); // Access by index
}
Documentation 📚 #
- 🦀 Rust Engine Docs – Full SQL reference and architecture details.
- 🎯 Vector Search Guide – Learn how to build semantic search.
- 🤝 Contributing – Help us build the future of mobile databases.
Advanced Features 🛠️ #
Semantic Vector Search #
Stoolap handles embeddings natively. No need for external Python scripts or API calls for distance calculations.
// Create table with vector support (384-dimensional)
await db.execute('''
CREATE TABLE items (
id INTEGER PRIMARY KEY,
description TEXT,
embedding VECTOR(384)
)
''');
// Perform semantic search using Cosine distance
final results = await db.query('''
SELECT description FROM items
ORDER BY VEC_DISTANCE_COSINE(embedding, EMBED(?))
LIMIT 5
''', params: ['high-performance database']);
Reactive Live Queries #
Use watch() to create a stream that automatically re-emits whenever the underlying tables change.
StreamBuilder<List<StoolapRow>>(
stream: db.watch('SELECT * FROM users ORDER BY id DESC'),
builder: (context, snapshot) {
if (!snapshot.hasData) return const CircularProgressIndicator();
final users = snapshot.data!;
return ListView.builder(
itemCount: users.length,
itemBuilder: (context, index) => ListTile(title: Text(users[index].values[1].toString())),
);
},
);
Join our community 🤝 #
We're building the most powerful embedded database for Flutter. Join us on GitHub to report issues, suggest features, or contribute code.
License #
Licensed under the Apache License, Version 2.0. See LICENSE for details.