Skip to content
pubscout

sqlparser

0.45.1, released 4 weeks ago by simonbinder.eu

SQL parser and static analyzer for SQLite written in Dart.

WASM-ready
$ flutter pub add sqlparser
Source repository

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 AST

Alternatives

Packages that do the same job and could replace sqlparser.

  • drift

    Higher‑level ORM that includes its own SQL parsing and generates type‑safe Dart code, reducing the need to use sqlparser directly.

Works with

Packages commonly used together with sqlparser: ones it builds on, ones built on it, and its own family.