Golem Add Mysql Moonbit
Agent Buildinggolem-add-mysql-moonbitGolem Add Mysql Moonbit is an Agent Skill for agent building published in the golemcloud/golem repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Using golem:rdbms/mysql from a MoonBit Golem agent. Use when the user asks to connect to MySQL, run SQL, or use MySQL from MoonBit agent code.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/golemcloud/golem/blob/HEAD/golem-skills/skills/moonbit/golem-add-mysql-moonbit/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/golem-add-mysql-moonbit, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Using MySQL from a MoonBit Agent
The MoonBit SDK already includes the generated package for golem:rdbms/[email protected].
Add the Package Import
In the component's moon.pkg, add an alias for the package:
import {
"golemcloud/golem_sdk/interface/golem/rdbms/mysql" @mysql,
}
Open a Connection
let conn = @mysql.DbConnection::open("mysql://user:password@localhost:3306/app")
.or_error!("failed to connect to MySQL")
Query Data
MySQL placeholders use ?.
let result = conn.query(
"SELECT ?",
[@mysql.DbValue::Varchar("hello")],
).or_error!("query failed")
let row = result.rows[0]
let value = row.values[0]
let message = match value {
@mysql.DbValue::Varchar(value) => value
@mysql.DbValue::Text(value) => value
@mysql.DbValue::Tinytext(value) => value
@mysql.DbValue::Mediumtext(value) => value
@mysql.DbValue::Longtext(value) => value
@mysql.DbValue::Fixchar(value) => value
_ => abort("unexpected MySQL value")
}
Execute Statements
conn.execute(
"INSERT INTO notes (id, body) VALUES (?, ?)",
[@mysql.DbValue::Int(1), @mysql.DbValue::Varchar("hello")],
).or_error!("insert failed")
Transactions
let tx = conn.begin_transaction().or_error!("failed to start transaction")
tx.execute(
"UPDATE notes SET body = ? WHERE id = ?",
[@mysql.DbValue::Varchar("updated"), @mysql.DbValue::Int(1)],
).or_error!("update failed")
tx.commit().or_error!("commit failed")