gorm-generic-interface

Retrieve the underlying *sql.DB* object from a GORM *gorm.DB* instance.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-generic-interface
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gorm-generic-interface
Source: https://github.com/liurida/gorm-development-skill/tree/main/generic_interface
Command: npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-generic-interface

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It simplifies obtaining the underlying database connection from a GORM instance and allows fine‑tuned pool configuration, enabling integration with other Go tools and performance monitoring.

Core Features & Use Cases

  • Access underlying DB: Retrieve the generic sql.DB object from a GORM gorm.DB for low‑level operations.
  • Connection pool tuning: Adjust maximum idle connections, maximum open connections, and connection lifetime.
  • Monitoring: Query pool statistics such as open, idle, and in‑use connections.
  • Use case: When you need to share the database handle with a library that expects sql.DB or when you want to optimize connection resources in a high‑throughput Go service.

Quick Start

Ask the skill to get the sql.DB from your GORM DB and set the desired pool limits.

Frequently Asked Questions about gorm-generic-interface

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

FAQPage Schema
How do I get the underlying sql.DB from a gorm.DB instance in Go?▼

You can retrieve the underlying sql.DB object from your gorm.DB instance to perform low-level database operations or configure connection pool parameters like MaxIdleConns, MaxOpenConns, and ConnMaxLifetime directly.

How do I configure GORM connection pool settings for a high-throughput Go service?▼

To configure GORM connection pool settings, retrieve the underlying sql.DB object and set MaxIdleConns, MaxOpenConns, and ConnMaxLifetime to optimize connection resources in high-throughput Go services.

Can I share my GORM database handle with another Go library that expects sql.DB?▼

Yes, you can share your database handle by retrieving the generic sql.DB object from the gorm.DB instance, enabling seamless integration with external Go libraries that require the standard database/sql package.

How do I monitor database connection pool statistics using GORM?▼

You can monitor database connection pool statistics by accessing the underlying sql.DB object from your gorm.DB instance, allowing you to query pool metrics such as open, idle, and in-use connections.

Do I need the database/sql package to tune GORM connection pool parameters?▼

Yes, you need the standard library's database/sql package to set connection pool parameters like MaxIdleConns, MaxOpenConns, and ConnMaxLifetime on the underlying sql.DB object extracted from the gorm.DB instance.