Skip to content
Back to skills

Database

ASecurity

This skill covers patterns for managing database sessions and models. Trigger: Load when working with database interactions.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 26, 2026
ai-agentspythonbashsqldatabasesecurity

Security analysis

A100/100

Scanned September 26, 2026

npx -y skills add JNZader/repoforge --skill database --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Database
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jnzader-database/badge)](https://www.skillsdirectory.com/skills/jnzader-database)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: manage-database-session
description: >
  This skill covers patterns for managing database sessions and models.
  Trigger: Load when working with database interactions.
license: Apache-2.0
metadata:
  author: repoforge
  version: "1.0"
  complexity: low
  token_estimate: 350
  dependencies: []
  related_skills: []
  load_priority: high
---

<!-- L1:START -->
# manage-database-session

This skill covers patterns for managing database sessions and models.

**Trigger**: Load when working with database interactions.
<!-- L1:END -->

<!-- L2:START -->
## Quick Reference

| Task | Pattern |
|------|---------|
| Create a database session | `get_db()` |
| Define a database model | `Base` |

## Critical Patterns (Summary)
- **Create a database session**: Use `get_db()` to create a session for database operations.
- **Define a database model**: Utilize `Base` to define your database models.
<!-- L2:END -->

<!-- L3:START -->
## Critical Patterns (Detailed)

### Create a database session

Use `get_db()` to create a session for database operations, ensuring proper management of database connections.

```python
from apps.server.app.models.database import get_db

async def some_database_operation():
    async with get_db() as session:
        # Perform database operations
        pass
```

### Define a database model

Utilize `Base` to define your database models, which will serve as the foundation for your ORM mappings.

```python
from apps.server.app.models.database import Base
from sqlalchemy import Column, Integer, String

class User(Base):
    __tablename__ = 'users'
    
    id = Column(Integer, primary_key=True, index=True)
    name = Column(String, index=True)
```

## When to Use

- When creating a new database session for CRUD operations.
- When defining new models for your database schema.

## Commands

```bash
python -m alembic upgrade head
```

## Anti-Patterns

### Don't: Use raw SQL queries directly

Using raw SQL queries bypasses the ORM and can lead to security vulnerabilities and maintenance issues.

```python
# BAD
async def raw_query():
    await db.execute("SELECT * FROM users")
```
<!-- L3:END -->

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.