Skip to content
Back to skills

2253 Sql 917d8914

ASecurity

Query databases and DataFrames using SQL with reactive integration.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
databasespythongobashsqlreactapidatabase

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 2253-sql_917d8914 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 2253 Sql 917d8914?

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

Security grade badge for 2253 Sql 917d8914
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-2253-sql-917d8914/badge)](https://www.skillsdirectory.com/skills/tools-only-2253-sql-917d8914)

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

SKILL.md
# SQL API Reference

Query databases and DataFrames using SQL with reactive integration.

## Overview

marimo enables mixing Python and SQL through `mo.sql()`. Query Python DataFrames, databases, files, and APIs, with results returned as DataFrames.

## Installation

```bash
pip install "marimo[sql]"
```

## Basic Usage

### mo.sql

Execute SQL queries.

```python
import marimo as mo

# Query a Python DataFrame
result = mo.sql(f"SELECT * FROM {df} WHERE value > 100")

# With f-string interpolation for reactivity
threshold = mo.ui.slider(0, 100, value=50)
result = mo.sql(f"SELECT * FROM {df} WHERE value > {threshold.value}")
```

## Creating SQL Cells

Three methods in the editor:
1. Right-click "add cell" → "SQL cell"
2. Convert empty cell via context menu
3. Click SQL button at notebook bottom

## Querying DataFrames

Reference Python DataFrames directly by variable name:

```python
# Python cell
import pandas as pd
sales_df = pd.DataFrame({"product": ["A", "B"], "revenue": [100, 200]})

# SQL cell
result = mo.sql(f"""
    SELECT product, revenue
    FROM {sales_df}
    WHERE revenue > 150
""")
```

## Database Connections

### UI Method

Click "Add Database Connection" in the SQL cell to configure:
- PostgreSQL
- MySQL
- SQLite
- DuckDB
- Snowflake
- BigQuery

### Code Method

```python
# SQLAlchemy
from sqlalchemy import create_engine
engine = create_engine("postgresql://user:pass@host/db")

# Use in SQL
result = mo.sql(f"SELECT * FROM users LIMIT 10", engine=engine)
```

Supported: SQLAlchemy, SQLModel, Ibis, DuckDB, ClickHouse Connect.

## Output Types

Configure output format:

```python
# Native DuckDB (recommended for large data)
result = mo.sql(f"SELECT * FROM {df}", output="native")

# Options: "native", "lazy-polars", "pandas", "polars", "auto"
```

## Querying Files

```python
# CSV
result = mo.sql(f"SELECT * FROM 'data.csv'")

# Parquet
result = mo.sql(f"SELECT * FROM 'data.parquet'")

# Remote files
result = mo.sql(f"SELECT * FROM 'https://example.com/data.csv'")

# S3
result = mo.sql(f"SELECT * FROM 's3://bucket/path/data.parquet'")
```

## Reactive Queries

SQL integrates with marimo's reactivity:

```python
# Cell 1
category = mo.ui.dropdown(["Electronics", "Books", "Clothing"])

# Cell 2 - re-runs when dropdown changes
filtered = mo.sql(f"""
    SELECT * FROM products
    WHERE category = '{category.value}'
""")
```

## Best Practices

- Use `output="native"` for large datasets
- Reference DataFrames with `{df}` syntax
- Use f-strings for reactive parameter binding
- Database tables take precedence over local DataFrames with same name

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.