scalar + exists

June 24, 2026 · View on GitHub

 ███████╗████████╗██████╗ ██╗   ██╗██╗  ██╗███████╗
 ██╔════╝╚══██╔══╝██╔══██╗╚██╗ ██╔╝██║ ██╔╝██╔════╝
 ███████╗   ██║   ██████╔╝ ╚████╔╝ █████╔╝ █████╗
 ╚════██║   ██║   ██╔══██╗  ╚██╔╝  ██╔═██╗ ██╔══╝
 ███████║   ██║   ██║  ██║   ██║   ██║  ██╗███████╗
 ╚══════╝   ╚═╝   ╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═╝╚══════╝
                   [ m s s q l ]

CI License: MIT stryke

[MICROSOFT SQL SERVER CLIENT FOR STRYKE // QUERY + EXECUTE + PARAMS + TRANSACTIONS + INTROSPECTION]

"T-SQL, one stryke pipe at a time."

Microsoft SQL Server / Azure SQL client for stryke. Parametrized query and execute, transaction batches, scalar/exists helpers, and schema introspection against any SQL Server 2012+ or Azure SQL — over tiberius (the pure-Rust TDS driver). Opt-in package tier.

strykelang · MenkeTechnologiesMeta · stryke-postgres · stryke-mysql

Read the Docs · Engineering Report


Table of Contents


[0x00] Install

s add github.com/MenkeTechnologies/stryke-mssql

On first use Mssql, stryke dlopens the cdylib in-process and registers every mssql__* export.


[0x01] Quick start

use Mssql

val %conn = (
    host       => "localhost",
    database   => "app",
    username   => "sa",
    password   => $ENV{MSSQL_PASS},
    trust_cert => 1,           # for a dev cert
)

# parametrized query — @P1, @P2, ...
val @users = Mssql::query("SELECT id, name FROM users WHERE active = @P1", params => [1], %conn)
p len(@users)

# scalar + exists
p Mssql::scalar("SELECT COUNT(*) FROM users", %conn)
p Mssql::exists("SELECT 1 FROM users WHERE id = @P1", params => [42], %conn)

# write
Mssql::execute("UPDATE users SET name = @P1 WHERE id = @P2", params => ["Ada", 42], %conn)

# transaction batch (commit on success, rollback on any failure)
Mssql::batch(
    ["INSERT INTO audit (msg) VALUES ('x')", "UPDATE users SET seen = 1 WHERE id = 42"],
    %conn,
)

[0x02] Connecting

%conn (or $MSSQL_URL as an ADO connection string fallback):

KeyDefaultNotes
urlADO string, e.g. Server=db;Database=app;User Id=sa;Password=...
host127.0.0.1
port1433
databaseserver default
usernameSQL auth user
passwordSQL auth password
encryptrequiredrequired, off, or not_supported
trust_certfalsetrue accepts a self-signed server cert (dev)

A tiberius Client is cached per (host, port, db, auth, encrypt); a connection that errors is evicted and reopened on the next call.


[0x03] Architecture

  • Drivertiberius, the pure-Rust TDS implementation. No FreeTDS, no ODBC, no system driver.
  • Blocking facade — tiberius is async, so the cdylib owns one tokio runtime and block_ons each call, matching the sync model the other stryke data packages use.
  • Typed rows — each cell is converted to JSON by trying the TDS types in order (int/float/bool/string/decimal/uuid/datetime/binary), so arbitrary result sets round-trip without a per-query schema. Decimals preserve precision as strings; binary is base64; datetimes are ISO-8601.
  • Pure helpers — the ADO parse/redact helpers take no connection and are unit-tested in-crate.

[0x04] API reference

GroupFunctions
Livenessversion, ping, server_version
Queryquery, query_one, scalar, exists, simple_query
Writeexecute, insert (multi-row), batch (transaction)
DDLcreate_table, drop_table, truncate
Introspectiondatabases, tables, columns, views, schemas, primary_keys, foreign_keys, indexes, table_exists, current_database, count, row_count
SQL helpersquote_ident, quote_literal, valid_identifier, escape_like, format_value, format_in_list, split_batch
URL helpersparse_url, redact_url, build_url

Parametrized statements use @P1, @P2, … placeholders bound from params (null / bool / integer / float / string).


[0x05] Build & test

make debug       # cargo build
make test        # cargo test, then `s test t/` (live needs $MSSQL_HOST)
make install     # s pkg install -g .

cargo test runs the in-crate unit tests (ADO parse/redact, defaults, param extraction) with no database. Point $MSSQL_HOST (+ $MSSQL_USER / $MSSQL_PASS) at a throwaway SQL Server container to exercise the query path.


[0x06] License

MIT · MenkeTechnologies