sqlparser
0.45.1, released 4 weeks ago by simonbinder.eu
SQL parser and static analyzer for SQLite written in Dart.
WASM-ready
What it does
Parses SQLite statements into an abstract syntax tree and performs static analysis such as type inference and error detection. It can resolve column types, infer variable types, and warn about semantic issues before execution.
AI-written summary of version 0.45.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to validate or analyze SQLite queries at compile‑time or runtime in a Dart/Flutter app.
- You are building a custom ORM, query builder, or tooling that requires understanding SQL structure without executing it.
Skip it when
- You need to actually execute SQL against a database; use sqflite, sqlite3, or drift instead.
- You only need a lightweight query builder without full parsing capabilities.
Strengths
- Full support for SQLite syntax including DDL, DML, and management statements.
- Static analysis provides type inference and early error detection.
- Integrates well with drift for type‑safe code generation.
Weaknesses
- Limited to SQLite dialect; cannot parse other SQL dialects.
- Provides parsing only, no database execution layer.
- May be overkill for simple query string handling.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
import 'package:sqlparser/sqlparser.dart';
final engine = SqlEngine();
final result = engine.parse(ParserEntrypoint.statement, '''
SELECT f.* FROM frameworks f
INNER JOIN uses_language ul ON ul.framework = f.id
INNER JOIN languages l ON l.id = ul.language
WHERE l.name = 'Dart'
ORDER BY f.name ASC, f.popularity DESC
LIMIT 5 OFFSET 5 * 3
''');
// result.rootNode contains the ASTAlternatives
Packages that do the same job and could replace sqlparser.
Works with
Packages commonly used together with sqlparser: ones it builds on, ones built on it, and its own family.
- source_spansqlparser depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- charcodesqlparser depends on itProvides named integer constants for ASCII and HTML character codes.
- drift_devBuilt on sqlparserGenerates Dart database code from Drift table definitions as a dev‑dependency.
- floorBuilt on sqlparserA SQLite abstraction library for Flutter inspired by Room.
- sql_crdtBuilt on sqlparserBase package for Conflict-free Replicated Data Types using SQL databases