knex_dart_mssql 0.3.2
knex_dart_mssql: ^0.3.2 copied to clipboard
Microsoft SQL Server driver for knex_dart — execute queries against SQL Server via the pure-Dart mssql package (TDS 7.4/8.0, no native dependencies).
knex_dart_mssql #
Microsoft SQL Server driver for knex_dart using mssql, a pure-Dart TDS 7.4/8.0 implementation — no native dependencies.
Installation #
dependencies:
knex_dart_mssql: ^0.3.2
Quick Start #
import 'package:knex_dart_mssql/knex_dart_mssql.dart';
final db = await KnexMssql.connect(
host: 'localhost',
database: 'AdventureWorks',
username: 'sa',
password: 's3cr3t!',
// Defaults: encrypt: true, trustServerCertificate: true — TLS is on, but
// the server's certificate isn't validated, matching most local/on-prem
// SQL Server instances, which present a self-signed certificate. Set
// trustServerCertificate: false for a server with a certificate from a
// trusted CA (e.g. Azure SQL).
);
final rows = await db.select(
db
.queryBuilder()
.table('users')
.where('active', '=', 1)
.orderBy('id')
.limit(10),
);
await db.close();
Platform Requirements #
- Pure Dart — no native library or system dependency required (no FreeTDS
install step). Works anywhere a Dart
Socket/SecureSocketdoes.
Dialect Capabilities #
knex_dart_capabilities does not currently include a dedicated mssql dialect entry, so static capability checks are not available yet for SQL Server.
Implemented driver/compiler highlights:
- MSSQL
OFFSET ... FETCH NEXT ...pagination compilation for.limit()/.offset(). having(...)andhavingRaw(...)compilation.- Window-function SQL generation from query builder methods.
Known Limitations #
- One physical connection per
KnexMssql/MssqlClientinstance — no connection pooling wired into this driver yet (the underlyingmssqlpackage has its ownMssqlPool, not yet adopted here). Unlike the previous driver, this connection is not a process-wide singleton: separateKnexMssql.connect()calls are fully independent. - SQL Server-specific bracket quoting (
[col]) is not emitted by default query compiler; useraw()when exact bracketed SQL is needed. - Alias aggregate expressions (for example
count(*) as total) so result keys are predictable.