The Dialect Interface
All dialects implement theDialect interface:
PostgreSQL Dialect
The PostgreSQL dialect uses the pg library.Installation
Basic Configuration
Lazy Pool Initialization
Create the pool only when first used:PostgreSQL-Specific Features
RETURNING clause:MySQL Dialect
The MySQL dialect uses the mysql2 library.Installation
Basic Configuration
Lazy Pool Initialization
MySQL-Specific Features
LIMIT with OFFSET:SQLite Dialect
The SQLite dialect uses the better-sqlite3 library.Installation
Basic Configuration
In-Memory Database
Lazy Database Initialization
SQLite-Specific Features
AUTOINCREMENT:MS SQL Server Dialect
The MS SQL Server dialect uses the tedious library with tarn for connection pooling.Installation
Basic Configuration
MS SQL-Specific Features
TOP clause:Dialect Comparison
Connection Pooling
Each dialect handles connection pooling differently: PostgreSQL (pg):Custom Dialects
You can create custom dialects by implementing theDialect interface:
Best Practices
Different dialects support different SQL features. Always check the dialect-specific documentation when using advanced features.