hmssql
hmssql is a native Haskell client for Microsoft SQL Server (2017 and later) and Azure SQL Database. It implements SQL Server’s wire protocol directly (TDS 7.4 and 8.0), so no ODBC driver or client library is needed.
Contents#
- Getting started
- A first program — Requirements, and a program that runs a query
- Connecting — Local servers, Azure SQL Database and Microsoft Entra ID
- Pools and threads — One thread per connection, and a pool recipe
- Queries
- Reading rows — Records, tuples and your own column types
- Parameters —
param,mkQueryand named parameters - Composing queries — Queries as values
- Several result sets — Reading the results of several
SELECTstatements in one batch - Stored procedures — Output parameters and the return status
- Writing data
- Transactions —
withTransactionand isolation levels - Many statements in one round trip —
executeManyandBatchQuery - Bulk copy — Inserting many rows efficiently
- Transactions —
- Streaming
- Streaming rows — Processing rows without collecting the whole result in memory
- MARS — Several open streams on one connection
- Decoders and encoders
- Decoders — Row decoders built by hand, and decoders chosen at runtime
- Encoders — How values are declared to the server, and encoders for your own types
- Streaming values — A single value too large for memory, in either direction
- Errors and security
- Errors and timeouts — Handling exceptions and setting timeouts
- Encryption and security — Encryption modes, certificates and credentials
- Under the hood
- How it works — The protocol, in one page
Where to go next#
- Examples — Complete programs over a sample database, among them a streaming OData server
- Developer documentation — Design decisions and implementation notes for contributors