drupal-database-api

Manage custom database tables and SQL queries using Drupal's Database API.

1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-database-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drupal-database-api
Source: https://github.com/proofoftom/drupal-skills/tree/main/skills/drupal-database-api
Command: npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-database-api

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a robust and secure way to interact with your Drupal site's database, enabling custom table creation, complex query writing, and schema management.

Core Features & Use Cases

  • Custom Table Management: Define and manage custom database tables using hook_schema() and update hooks.
  • Secure Querying: Write dynamic and static SQL queries safely using Drupal's Database API, preventing SQL injection.
  • Schema Evolution: Handle database schema changes gracefully with update hooks and batch processing.
  • Use Case: You need to store custom log data for your module. This Skill helps you define a new table, insert log entries, and retrieve them efficiently.

Quick Start

Use the drupal-database-api skill to define a new table named 'my_log_table' with columns 'message' (text) and 'timestamp' (int) in your module's install file.

Frequently Asked Questions about drupal-database-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define a custom database table in a Drupal module?

To define a custom database table in Drupal, implement `hook_schema()` in your module's install file to declare the table structure and columns. This ensures the table is created during module installation.

What is the best way to write secure SQL queries in Drupal?

The best way to write secure SQL queries in Drupal is using the Database API with placeholders for dynamic data. This approach prevents SQL injection by ensuring data is properly escaped during query execution.

How do I handle database schema changes when updating a Drupal module?

To handle database schema changes in Drupal, implement update hooks in your module's install file. This allows you to apply incremental schema evolutions and manage data migrations safely across module versions.

Can I use dynamic queries with Drupal's query alteration system?

Yes, you can use dynamic queries with Drupal's query alteration system. The Database API supports building dynamic queries that are fully compatible with hook_query_alter(), allowing other modules to modify queries at runtime.