SQLite
SQLite is the default scaffold for new projects. It runs without external services and is great for local development, CLI tools, and fast integration tests.
Install
Add the driver package:
dependencies:
ormed: ^latest
ormed_sqlite: ^latest
Configure (ormed.yaml)
driver:
type: sqlite
options:
database: database.sqlite # relative to project root
Use in code (DataSource)
Future<DataSource> createSqliteDataSource() async {
final dataSource = DataSource(
DataSourceOptions(
name: 'default',
driver: SqliteDriverAdapter.file('database.sqlite'),
entities: generatedOrmModelDefinitions,
),
);
await dataSource.init();
return dataSource;
}
SQLite Migrations Helpers
Import the SQLite migrations entrypoint to use SQLite-specific column aliases:
import 'package:ormed_sqlite/migrations.dart';
Available helpers:
blob()→ BLOB (alias forbinary())real()→ REAL (alias forfloat())numeric()→ NUMERIC (alias fordecimal())
In-memory (tests)
DataSource createInMemorySqliteDataSource() {
return DataSource(
DataSourceOptions(
name: 'test',
driver: SqliteDriverAdapter.inMemory(),
entities: generatedOrmModelDefinitions,
),
);
}
Options
| Option | Type | Default | Description |
|---|---|---|---|
database | String | database.sqlite | Path to the .sqlite file (relative to project root or absolute). |
path | String? | — | Alias for database used by some programmatic helpers. |
memory | bool | false | When true, connects to an in-memory database (tests / ephemeral usage). |
Notes
- The adapter automatically enables
RETURNINGsupport and schema inspection. - Migrations and seeds are configured separately in
ormed.yaml. See Getting Started → Configuration. - For plan/previews/schema internals, see Drivers → Internals.