Xpersona
S

SQL Connector

CLAWHUB · Unverified

Generic SQL Server connectivity for OpenClaw agents. Use when: (1) executing parameterized queries against SQL Server, (2) building repository layers that ne... Skill: SQL Connector Owner: oblio-falootin Summary: Generic SQL Server connectivity for OpenClaw agents. Use when: (1) executing parameterized queries against SQL Server, (2) building repository layers that ne... Tags: latest:2.2.0 Version history: v2.2.0 | 2026-04-28T17:47:46.866Z | user GETTING_STARTED.md (494 lines) and SKILL_REFERENCE.md (712 lines) added. Publish workflow added. Custom backend naming documented.

62
Rank
84
Safety
1.4k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.4K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s178hc1brh9m5mmh3hnb27txnx83j824:sql-connector
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-oblio-falootin-sql-connector/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

68,967 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: sql-connector
version: 2.1.0-alpha
status: alpha
description: "Generic SQL Server connectivity for OpenClaw agents. Use when: (1) executing parameterized queries against SQL Server, (2) building repository layers that need a sealed, retry-capable SQL transport, (3) any agent that needs reliable MSSQL access without subprocess/sqlcmd. Provides execute/query/scalar APIs via pymssql with automatic retry, connection pooling, and structured error handling. ALPHA: use at your own risk, API may change."
---

# SQL Connector Skill
> Generic SQL Server connectivity for OpenClaw agents — pymssql transport

## Overview

Provides a reusable, sealed SQL Server connection layer with automatic retry, parameterized queries, and structured error handling. Built on **pymssql** (native TDS driver — no sqlcmd required).

## Installation

```bash
clawhub install sql-connector
```

## Quick Start

```python
from sql_connector import get_connector

db = get_connector('cloud')   # or 'local'

# Execute (INSERT/UPDATE/DELETE)
ok = db.execute("INSERT INTO memory.Logs (msg) VALUES (%s)", ("hello",))

# Query (SELECT → list of dicts)
rows = db.query("SELECT id, name FROM memory.Memories WHERE category=%s", ("facts",))

# Scalar (single value)
count = db.scalar("SELECT COUNT(*) FROM memory.TaskQueue WHERE status='pending'")
```

## Environment Variables

```
SQL_CLOUD_SERVER=sql5112.site4now.net
SQL_CLOUD_DATABASE=db_99ba1f_memory4oblio
SQL_CLOUD_USER=...
SQL_CLOUD_PASSWORD=...

SQL_LOCAL_SERVER=10.0.0.110
SQL_LOCAL_DATABASE=Oblio_Memories
SQL_LOCAL_USER=sa
SQL_LOCAL_PASSWORD=...
```

## Architecture

```
SQLConnector (ABC, _LockCoreMethods metaclass)
  execute() / query() / scalar()  ← SEALED — parameterized only, no override
  MSSQLConnector (pymssql, TDS 7.4)
    └── get_connector(backend) factory
```

`execute()` and `query()` are sealed by metaclass — subclasses cannot override them, enforcing parameterized-only access.

## License

MIT

README.md

# clawbot-sql-connector

> **STABLE** — Battle-tested in production. API is stable as of v2.0.

A sealed, retry-capable SQL Server connector for OpenClaw agents. Built on **pymssql** — no `sqlcmd`, no ODBC drivers, no system tools required.

📚 **Documentation**
- **[GETTING STARTED](./GETTING_STARTED.md)** — Installation, setup, configuration, quick examples (15 min read)
- **[SKILL REFERENCE](./SKILL_REFERENCE.md)** — Full API, architecture, error handling, performance tips, advanced usage

🚀 **Getting Started (TL;DR)**
1. `pip install clawbot-sql-connector`
2. Set credentials in `.env` (cloud or local)
3. `from sql_connector import get_connector; db = get_connector(); db.ping()`
4. Use `db.query()`, `db.execute()`, `db.scalar()`

## Features

- **Multi-backend:** `local` (on-prem) and `cloud` (hosted) in one connector
- **Env-var driven default:** set `SQL_DEFAULT_BACKEND` in `.env` — no code change needed
- **Sealed transport:** `execute()` and `query()` sealed via metaclass — subclasses cannot bypass parameterized queries
- **Automatic retry:** retry 3x with exponential backoff (2s) on transient failures
- **Structured errors:** `SQLConnectionError` (transient) vs `SQLQueryError` (permanent)
- **Operations:** `execute()` (INSERT/UPDATE/DELETE), `query()` (SELECT → list of dicts), `scalar()` (single value), `ping()` (health check)
- **Production-ready:** connection pooling, timeout handling, no hardcoded credentials
- **Dependencies:** Only `pymssql` + `python-dotenv` (no ODBC, no system packages)

## Quick Start

For full setup including configuration examples, see **[GETTING STARTED](./GETTING_STARTED.md)**.

### Installation

```bash
# Via ClawHub (recommended)
clawhub install sql-connector

# Or direct pip
pip install clawbot-sql-connector pymssql python-dotenv
```

### Configure

Create `.env` in your workspace with SQL Server credentials:

**Cloud (Azure, site4now, etc.):**
```env
SQL_CLOUD_SERVER=your-server.database.windows.net
SQL_CLOUD_DATABASE=your_database
SQL_CLOUD_USER=your_user@server
SQL_CLOUD_PASSWORD=your_password
SQL_DEFAULT_BACKEND=cloud
```

**Local (on-prem):**
```env
SQL_LOCAL_SERVER=10.0.0.110
SQL_LOCAL_DATABASE=your_database
SQL_LOCAL_USER=sa
SQL_LOCAL_PASSWORD=your_password
SQL_DEFAULT_BACKEND=local
```

### Quick Example

```python
from sql_connector import get_connector, SQLConnectionError

db = get_connector()  # uses SQL_DEFAULT_BACKEND from .env

# SELECT (returns list of dicts)
rows = db.query(
    "SELECT TOP 5 id, content FROM memory.Memories WHERE category = %s",
    ('facts',)
)

# INSERT/UPDATE/DELETE (returns bool)
success = db.execute(
    "INSERT INTO memory.Memories (category, key, content) VALUES (%s, %s, %s)",
    ('facts', 'obs_001', 'Pattern discovered')
)

# Single value (COUNT, MAX, etc.)
count = db.scalar(
    "SELECT COUNT(*) FROM memory.Memories WHERE category = %s",
    ('facts',)
)

# Health check
if db.ping():
    print("✅ Database online")
```

## Design Principles

### Parameterized Quer

_meta.json

{
  "ownerId": "kn73kshndq5w6jhda1m0j558g181t6yy",
  "slug": "sql-connector",
  "version": "2.2.0",
  "publishedAt": 1777398466866
}

GETTING_STARTED.md

# GETTING STARTED: SQL Connector

**For:** OpenClaw agents that need reliable SQL Server access  
**Time Required:** 10 minutes setup + 5 minutes configuration  
**Prerequisites:** OpenClaw installed, SQL Server (cloud or local), basic Python knowledge

---

## Overview: What is SQL Connector?

SQL Connector is a **sealed, retry-capable SQL Server transport** for OpenClaw agents. It handles:

- ✅ Multi-backend connections (local + cloud)
- ✅ Automatic retry on transient failures
- ✅ Parameterized queries (SQL injection safe)
- ✅ Structured error handling
- ✅ No system tools required (everything in Python)

**Why use it:**
- Your agents need SQL access without subprocess/sqlcmd
- You want **guaranteed parameterized queries** (sealed by metaclass)
- You need automatic retry and exponential backoff
- Your `.env` drives connection choice — no code change

**Who uses it:**
- SQL Memory (stores agent findings)
- SQL Dreamer (reads memories, dreams)
- Any agent querying production databases

---

## Step 1: Install SQL Connector

```bash
# Via ClawHub (recommended)
clawhub install sql-connector

# Or manually via pip
pip install clawbot-sql-connector pymssql python-dotenv
```

### Verify Installation

```bash
python3 << 'PYTHON'
from sql_connector import get_connector, SQLConnector
print("✅ SQL Connector imported successfully")
PYTHON
```

---

## Step 2: Configure Connection

Create a `.env` file in your OpenClaw workspace root with your SQL Server credentials.

### Find Your Workspace

```bash
# Locate OpenClaw workspace
openclaw status
# Look for: repo=/path/to/.openclaw/workspace
```

### Create .env File

```bash
cd ~/.openclaw/workspace
cp .env.example .env    # or create new file
```

### For Cloud SQL Server (Azure, site4now, etc.)

Edit `.env`:

```env
SQL_CLOUD_SERVER=your-server.database.windows.net
SQL_CLOUD_DATABASE=your_database_name
SQL_CLOUD_USER=your_username@yourserver
SQL_CLOUD_PASSWORD=your_password
SQL_DEFAULT_BACKEND=cloud
```

**Example (Azure):**
```env
SQL_CLOUD_SERVER=mycompany.database.windows.net
SQL_CLOUD_DATABASE=prod_memories
SQL_CLOUD_USER=admin@mycompany
SQL_CLOUD_PASSWORD=Sup3rS3cr3t!
SQL_DEFAULT_BACKEND=cloud
```

### For Local SQL Server (On-Prem / Self-Hosted)

Edit `.env`:

```env
SQL_LOCAL_SERVER=10.0.0.110
SQL_LOCAL_DATABASE=your_database_name
SQL_LOCAL_USER=your_username
SQL_LOCAL_PASSWORD=your_password
SQL_DEFAULT_BACKEND=local
```

**Example (Oblio setup):**
```env
SQL_LOCAL_SERVER=10.0.0.110
SQL_LOCAL_DATABASE=db_99ba1f_memory4oblio
SQL_LOCAL_USER=oblio
SQL_LOCAL_PASSWORD=MySecurePassword123
SQL_DEFAULT_BACKEND=local
```

### For Mixed Setup (Both Local + Cloud)

You can set **both** and switch via code:

```env
# Local (primary)
SQL_LOCAL_SERVER=10.0.0.110
SQL_LOCAL_DATABASE=db_99ba1f_memory4oblio
SQL_LOCAL_USER=oblio
SQL_LOCAL_PASSWORD=xxx

# Cloud (fallback/testing)
SQL_CLOUD_SERVER=your-server.database.windows.net
SQL_CLOUD_DATABASE=your_database
SQL_CLOUD_USER=your_user
SQL_CLOUD_PASSWORD=xxx

# Which to 

SKILL_REFERENCE.md

# SKILL REFERENCE: SQL Connector

**For:** Developers building on SQL Connector, advanced users, agents needing production reliability  
**Scope:** Architecture, API reference, error patterns, performance optimization, advanced usage

---

## Quick Reference

| Operation | Method | Returns | Safe? |
|-----------|--------|---------|-------|
| SELECT query | `query(sql, params)` | `list[dict]` | ✅ Parameterized |
| INSERT/UPDATE/DELETE | `execute(sql, params)` | `bool` | ✅ Parameterized |
| Single value | `scalar(sql, params)` | `Any` | ✅ Parameterized |
| Health check | `ping()` | `bool` | ✅ Read-only |
| Get instance | `get_connector(backend)` | `SQLConnector` | N/A |

---

## Architecture

### Layer Model

```
┌────────────────────────────────────────┐
│  Your Code (agents, scripts)           │
│  from sql_connector import get_connector
│  db = get_connector('cloud')           │
└─────────────────┬──────────────────────┘
                  │
                  ▼
┌────────────────────────────────────────┐
│  Factory: get_connector(backend)       │
│  ├─ 'cloud' → MSSQLConnector(cloud)    │
│  └─ 'local' → MSSQLConnector(local)    │
└─────────────────┬──────────────────────┘
                  │
                  ▼
┌────────────────────────────────────────┐
│  SQLConnector (ABC + Metaclass)        │
│  _LockCoreMethods metaclass enforces   │
│  parameterized-only access             │
│                                        │
│  Public API:                           │
│  ├─ execute() — SEALED                 │
│  ├─ query() — SEALED                   │
│  ├─ scalar() — SEALED                  │
│  └─ ping()                             │
└─────────────────┬──────────────────────┘
                  │
                  ▼
┌────────────────────────────────────────┐
│  MSSQLConnector (pymssql impl)         │
│  ├─ Connection pooling                 │
│  ├─ Automatic retry (3x, 2s backoff)   │
│  └─ Structured error handling          │
└─────────────────┬──────────────────────┘
                  │
                  ▼
┌────────────────────────────────────────┐
│  pymssql (TDS 7.4 protocol)            │
│  └─ Native SQL Server driver           │
│     (no ODBC, no system packages)      │
└─────────────────┬──────────────────────┘
                  │
                  ▼
         SQL Server Database
         (Cloud or Local)
```

### Sealed Transport Pattern

The **metaclass `_LockCoreMethods`** prevents subclasses from overriding core methods:

```python
# This is BLOCKED by metaclass:
class BadConnector(MSSQLConnector):
    def query(self, sql, params=()):
        # CANNOT override - metaclass prevents it
        return super().query(sql, f"SELECT * FROM {sql}")  # ❌ Never runs
    
# ✅ This is ALLOWED - extend via composition/delegation:
class GoodRepository(MSSQLConnector):
    def get_facts(self, limit=10):
        # Cannot override query(), so we call it properly
        return self.query(
            "SELECT TOP %s * FROM memory.Memories WHERE category=%

Sponsored

Ads related to SQL Connector and adjacent AI workflows.