agentsclimarketplace

Sql params generate

Skill koriym/Koriym.SqlQuality/skills/sql-params-generate

Generate parameter bindings for SQL files by analyzing database schema and extracting SQL placeholders. Queries the live database for table structures, matches placeholders to column types, and generates appropriate test values based on column patterns (IDs, dates, status enums, etc).From its SKILL.md

Install
npx -y skills add koriym/Koriym.SqlQuality --skill sql-params-generate

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.5 KB, as published. Nobody here has run it

SQL Parameters Generator

Generate parameter bindings for SQL files by analyzing database schema and SQL placeholders.

Arguments

  • $ARGUMENTS: SQL directory path (e.g., "tests/sql")

Prerequisites

  • MySQL/MariaDB database must be running with the target schema loaded

Steps

1. Get Schema from Database

Query the database directly for the latest schema:

-- Get all tables
SHOW TABLES;

-- For each table, get columns
SELECT column_name, data_type, column_type, column_key
FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = 'table_name';

-- Or use SHOW CREATE TABLE for complete DDL
SHOW CREATE TABLE table_name;

2. Scan SQL Files

For each .sql file in the directory:

  1. Extract placeholder parameters (:param_name or ? style)
  2. Parse SQL to identify referenced tables and columns
  3. Match placeholders to column types from schema

3. Generate Values by Type

Column PatternTypeGenerated Value
*_id, idINTrand(1, 1000)
statusVARCHAR/ENUMPick from actual ENUM values or common: 'active', 'pending'
emailVARCHAR'[email protected]'
name, titleVARCHAR'Test Value'
*_at, *_dateDATETIME/DATE'2024-01-01'
price, amount, total*DECIMAL100.00
count, quantity, limitINT10
is_*, has_*TINYINT1
content, body, textTEXT'Sample text content'

4. Write Parameter File

Output to {sql_dir}/../params/sql_params.php:

<?php

declare(strict_types=1);

return [
    '1_full_table_scan.sql' => ['min_views' => 1000],
    '2_filesort.sql' => ['status' => 'published', 'limit' => 10],
    // SQL files without placeholders use empty array
    '12_select1.sql' => [],
];

5. Validation

  • Warn if placeholder cannot be matched to any column
  • Skip files that are DDL-only (CREATE, DROP, ALTER)
  • Report any SQL files missing from output

Database Connection

Use the same connection settings as sql-quality:

  • DSN: mysql:host=127.0.0.1;dbname=test
  • User: root
  • Password: (empty)

Or read from environment / config file if available.

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.