All examples
Databases

SQL Server samples to a feature tensor

Bind Unicode parameters through native ODBC Driver 18, retain exact result types and convert three numeric features to a tensor.

db_mssql.aner
// Public placeholders only. Configure privately: aner secrets set demo-mssql-password
import aner.db;
import aner.db.mssql;
import aner.secrets;
import aner.data;
import aner.tensor;

let connection: DBConnection = mssql.connect(
    host: "sql.example.invalid", port: 1433, database: "example_science",
    user: "example_reader", password: secrets.stored("demo-mssql-password"),
    sslmode: "verify-full", timeout_seconds: 10);
// Run examples/fixtures/db_mock_mssql.sql once with your administration tool.
// Native ODBC binds ? parameters separately from the SQL text.
let result: DBResult = db.query(connection,
    "SELECT sample_id, feature_a, feature_b, feature_c, label FROM aner_demo.samples WHERE label = CAST(? AS int) ORDER BY sample_id",
    List("2"), max_rows: 1000, max_bytes: 1048576);
print(db.rows(result));
let table: DataTable = db.to_table(result, 1048576);
print(data.integer(table, 0, "label"));
let features = db.query(connection,
    "SELECT feature_a, feature_b, feature_c FROM aner_demo.samples ORDER BY sample_id",
    List(), max_rows: 1000, max_bytes: 1048576);
let matrix = data.to_tensor(db.to_table(features, 1048576), 1048576);
print(tensor.rows(matrix));
db.close(connection);

Make it your experiment.

With Aner installed, save this program as examples/db_mssql.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/db_mssql.aner
aner run examples/db_mssql.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use a compatible installed Aner executable with native ODBC support and the separately installed Microsoft ODBC Driver 18 for SQL Server. Check db.available for the selected connector. In a dedicated development database, run db_mock_mssql.sql once with your database administration tool before running Aner. Replace the fictional host, database and username privately. Store the password with the credential setup commands below, or select an explicit environment/file reference as explained in the connector and Credentials guides. Configure a trusted CA and a hostname matching the server certificate. The examples keep verified TLS enabled. Checking the source opens no database connection; running connects to your configured server.

Credential setup
aner secrets set demo-mssql-password --store system
aner secrets status demo-mssql-password --store system

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner