Available

amalgame-mysql

Dynamic-link binding to libmariadb. MariaDB ≥ 10.x and MySQL ≥ 5.7.

amc package add mysql GitHub ↗ ← Back to the ecosystem

Overview

The MariaDB client is wire-protocol compatible with MySQL. The package links to the system's libmariadb, which talks to both MariaDB and a recent MySQL equally well.

Features

  • ✓MariaDB ≥ 10.x and MySQL ≥ 5.7 compatible (shared wire protocol)
  • ✓MySQL.Open(host, port, user, password, db), Exec, QueryAll, LastInsertId
  • ✓? parameters sent through libmariadb prepared statements, Begin / Commit / Rollback transactions
  • ✓Dynamic-link pattern — no vendored fork to maintain

Planned

  • ◐TLS settings in the API
  • ◐Typed column accessors: today every cell comes back as text
  • ◐Multiple result sets and async queries
  • ◐Stored-procedure OUT parameters

Example

Minimal usage example — copy-paste runnable after install.

import Amalgame.Database.MySQL

public class Program {
    public static void Main() {
        let db = MySQL.Open("127.0.0.1", 3306, "app", "secret", "shop")
        if (!MySQL.IsOpen(db)) {
            Console.WriteLine("connect failed: " + MySQL.LastError(db))
            return
        }
        let params = new List<string>()
        params.Add("42")
        let rows = MySQL.QueryBindAll(db, "SELECT id, total FROM orders WHERE customer_id = ?", params)
        for row in rows {
            Console.WriteLine(row.Get(0) + " : " + row.Get(1))
        }
        MySQL.Close(db)
    }
}

At a glance

Related packages