typed_sql
0.1.14, released 9 weeks ago by google.dev
Type-safe SQL queries and schema definitions using code generation.
What it does
Provides a type-safe API for interacting with SQL databases like SQLite and Postgres in Dart. It uses build_runner code generation to map tables and rows, allowing you to build queries using a fluent API with strong null-safety guarantees.
AI-written summary of version 0.1.14, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want compile-time type safety for your SQL queries in Dart
- You are targeting SQLite or Postgres and want a fluent query builder
- You prefer generating Dart classes from schema definitions
Skip it when
- You need support for databases other than SQLite and Postgres
- You prefer writing raw SQL strings without code generation
- You need a production-ready and fully stable database ORM
Strengths
- Strict type and null-safety matching database constraints
- Fluent extension-method based query builder
- Supports SQLite and Postgres natively
Weaknesses
- Under active development with potential breaking changes
- Requires setup with build_runner code generation
- Limited database backend support
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 11
Requires adding typed_sql and dev:build_runner, then executing 'dart run build_runner build' to generate model part-files.
abstract final class Bookstore extends Schema {
Table<Author> get authors;
Table<Book> get books;
}
@PrimaryKey(['authorId'])
abstract final class Author extends Row {
@AutoIncrement()
int get authorId;
@Unique.field()
String get name;
}Alternatives
Packages that do the same job and could replace typed_sql.
Works with
Packages commonly used together with typed_sql: ones it builds on, ones built on it, and its own family.
- analyzertyped_sql depends on itPerforms static analysis of Dart code for tool integration and embedding.
- globtyped_sql depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- code_buildertyped_sql depends on itA fluent, builder-based library for generating valid Dart code programmatically.
- converttyped_sql depends on itEncoders and decoders for converting between different data representations.
- buildtyped_sql depends on itPackage for authoring build_runner compatible code generators.
- source_gentyped_sql depends on itSource code generation builders and utilities for the Dart build system.
- sqlite3typed_sql depends on itLightweight and convenient SQLite bindings for Dart using dart:ffi
- postgrestyped_sql depends on itPostgreSQL driver for Dart supporting binary protocol, pooling and statement reuse.