Skip to main content

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 for binary())
  • real() → REAL (alias for float())
  • numeric() → NUMERIC (alias for decimal())

In-memory (tests)

DataSource createInMemorySqliteDataSource() {
return DataSource(
DataSourceOptions(
name: 'test',
driver: SqliteDriverAdapter.inMemory(),
entities: generatedOrmModelDefinitions,
),
);
}

Options

OptionTypeDefaultDescription
databaseStringdatabase.sqlitePath to the .sqlite file (relative to project root or absolute).
pathString?Alias for database used by some programmatic helpers.
memoryboolfalseWhen true, connects to an in-memory database (tests / ephemeral usage).

Notes

  • The adapter automatically enables RETURNING support and schema inspection.
  • Migrations and seeds are configured separately in ormed.yaml. See Getting Started → Configuration.
  • For plan/previews/schema internals, see Drivers → Internals.