mcpField
O
oxmysql

oxmysql

github.com/germanfndezData & databases1978 installsUpdated 2w ago
Repository

About oxmysql

oxmysql is a skill that guides server-side database code for FiveM resources using oxmysql's Lua or JavaScript APIs. It covers query selection, positional placeholders, transactions, and migration away from mysql-async compatibility syntax.

Key features

  1. 01Selects APIs by expected result shape
  2. 02Uses positional SQL placeholders
  3. 03Guides atomic multi-query transactions
  4. 04Covers prepared and raw execution
  5. 05Enforces server-side FiveM setup rules

Use cases

  1. 01Writing database queries in a FiveM resource
  2. 02Migrating mysql-async database code
  3. 03Implementing atomic multi-statement writes

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/germanfndez/fiveai-skills --skill oxmysql

After installing, type/oxmysqlin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

rules/
insert.md
placeholders.md
prepare.md
query.md
rawExecute.md
scalar.md
single.md
transaction.md
update.md

Details

From the project README

oxmysql

Server-side MySQL/MariaDB access for FiveM through the MySQL table (replacement for mysql-async and ghmattimysql).

Activation Contract

Load this skill when the user writes or edits database code in a FiveM resource: SELECT/INSERT/UPDATE/DELETE, upserts, transactions, MySQL.*, exports.oxmysql, or migrating from mysql-async.

Hard Rules

  • Server only. Add server_script '@oxmysql/lib/MySQL.lua' to fxmanifest.lua above other server scripts.
  • MySQL.Sync.* and MySQL.Async.* (mysql-async compatibility layer) are NOT available. Replace them with MySQL.query, MySQL.scalar, MySQL.single, MySQL.insert, MySQL.update, MySQL.prepare, MySQL.transaction, each with a .await variant.
  • @named placeholders are deprecated: use positional ? with an array of values. prepare accepts only ? (and ?? for column names).
  • Never concatenate user input into SQL; every value goes through a placeholder.
  • Every function takes (query, params, callback); use .await to yield instead of nesting callbacks.
  • Use transaction when several writes must succeed or fail together; it rolls back on any failure.
  • Use rawExecute only when the normalized result shape of query/prepare is insufficient.
  • Prefer MariaDB over MySQL 8 for compatibility.

Decision Gates

NeedCallReturns
Many rowsMySQL.query.await(sql, params)array of rows
One rowMySQL.single.await(sql, params)row or nil
One value (COUNT, one column)MySQL.scalar.await(sql, params)value or nil
InsertMySQL.insert.await(sql, params)insert id
Update / delete countMySQL.update.await(sql, params)affected rows
Hot path, repeated statementMySQL.prepare.await(sql, params)rows / value
Several statements atomicallyMySQL.transaction.await({ { query, values }, ... })success boolean
Raw, unnormalized resultMySQL.rawExecute.await(sql, params)raw result

Execution Steps

  1. Confirm the manifest line and that oxmysql starts before the resource.
  2. Pick the function by result shape from Decision Gates.
  3. Write the SQL with backticked identifiers and ? for every value.
  4. Wrap multi-statement writes in transaction.
  5. Handle nil results (single, scalar) before use.

Output Contract

Return runnable server-side Lua (or JS) using MySQL.<fn>.await with positional placeholders and no mysql-async syntax.

References

  • rules/placeholders.md — ? placeholders, deprecated @named.
  • rules/query.md — MySQL.query: rows or insertId/affectedRows.
  • rules/single.md — MySQL.single: one row or nil.
  • rules/scalar.md — MySQL.scalar: single value.
  • rules/insert.md — MySQL.insert: returns insert id.
  • rules/update.md — MySQL.update: returns affected rows.
  • rules/prepare.md — MySQL.prepare: prepared statements.
  • rules/transaction.md — MySQL.transaction: atomic multi-query.
  • rules/rawExecute.md — MySQL.rawExecute: raw result.

Upstream docs: https://overextended.dev/oxmysql

Comments

Markdown supported