Database Query Patterns (tkms) for Openclaw

Streamline database access layer development using standardized async SQL patterns and the tkms template.

laimiaohua
v1.0.0
Mar 17, 2026
0
1.5k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install gi-database-query-patterns

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install gi-database-query-patterns using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Database Query Patterns (tkms)?

This skill provides a standardized framework for implementing the Data Access Object (DAO) layer using the tkms AsyncSqlSessionTemplate. It focuses on asynchronous MySQL 8.0 operations, ensuring developers follow best practices for data integrity, performance, and maintainability. By leveraging Openclaw Skills, you can automate the generation of robust database interaction code that adheres to strict SQL standards and parameterized query protocols.

Database Query Patterns (tkms) Use Cases

  • Implementing data access logic within the app/dao directory.
  • Designing database schemas, indexes, and optimized SQL queries.
  • Handling complex CRUD operations like batch inserts or paginated list queries.
  • Managing asynchronous database sessions in high-performance Python applications.

How Database Query Patterns (tkms) Works

  1. Initialize the AsyncSqlSessionTemplate within your DAO class to manage connections.
  2. Define the target table and data entity mapping for insertion or updates using the params argument.
  3. Execute parameterized SQL queries using session methods like query_one or query_list to prevent injection.
  4. Map raw row results back to Python entities or data classes to ensure type safety across the application.
  5. Apply pagination logic using limit and offset parameters for efficient data retrieval in list queries.

Database Query Patterns (tkms) Setup

To integrate this into your project, ensure the tkms framework is available in your environment. Use the following command to prepare your workspace:

# Ensure your environment is configured for tkms database modules
pip install tkms

Configure your database connection settings to point to a MySQL 8.0 instance and import the AsyncSqlSessionTemplate into your DAO components.

Database Query Patterns (tkms) Data Schema & Taxonomy

The skill follows a strict data organization pattern to ensure consistency across Openclaw Skills implementations:

Component Description
Primary Key Uses tid (BIGINT) with AUTO_INCREMENT as the standard unique identifier.
Entity Mapping Maps Python dictionaries or objects to SQL columns via the params argument.
Meta Fields Includes create_time and update_time (DATETIME) for automated auditing.
Charset Defaulted to utf8mb4 for comprehensive Unicode and emoji support.
Indexing Standard indexes on status and create_time for optimized filtering.

Database Query Patterns (tkms) Advanced Features

  • Automatic primary key handling for auto-incrementing fields during insert operations.
  • Built-in support for complex JOIN and IN clauses to eliminate N+1 query performance issues.
  • Integrated transaction management for atomic multi-step operations to maintain data consistency.
  • Strict enforcement of parameterized queries using the :param syntax for maximum security against SQL injection.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*