sqlspec

Provide type-safe SQL query mapping for Python with database adapter support.

15|4|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/cofin/flow --skill sqlspec
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlspec
Source: https://github.com/cofin/flow/tree/main/skills/sqlspec
Command: npx skills add https://github.com/cofin/flow --skill sqlspec

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a robust and type-safe way to interact with various SQL databases from Python, abstracting away many of the complexities of direct database interaction and ensuring data integrity.

Core Features & Use Cases

  • Type-Safe SQL: Ensures parameters and results are handled with type information throughout the pipeline.
  • Multi-Adapter Support: Connects to a wide range of databases including PostgreSQL, MySQL, SQLite, BigQuery, and more.
  • Framework Integration: Seamlessly integrates with web frameworks like Litestar, FastAPI, and Starlette.
  • Use Case: Develop a Python application that needs to read and write data to a PostgreSQL database, ensuring that all SQL queries are validated and parameters are correctly typed before execution, and then deploy it using Litestar with automatic transaction management.

Quick Start

Use the sqlspec skill to connect to a PostgreSQL database using the provided DSN and execute a SELECT query.

Frequently Asked Questions about sqlspec

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

FAQPage Schema
How do I ensure type safety for SQL queries in Python?

Type safety for SQL queries in Python is ensured by using a mapping layer that validates parameters and processes results with type information throughout the pipeline. It leverages sqlglot for AST parsing and validation across diverse SQL dialects.

Can I use this type-safe SQL mapper with FastAPI or Litestar?

Yes, the type-safe SQL mapper seamlessly integrates with web frameworks like FastAPI, Litestar, and Starlette. It facilitates database interaction through a consistent API, parameter handling, and automatic transaction management for deployed applications.

What is the best way to connect Python to multiple SQL databases like PostgreSQL and BigQuery?

The best way to connect Python to multiple SQL databases like PostgreSQL and BigQuery is using a multi-adapter mapping layer. It abstracts database interaction complexities, offering a consistent API and ensuring data integrity across various supported adapters.

How do I execute a SELECT query in Python with validated SQL parameters?

To execute a SELECT query with validated SQL parameters in Python, use a type-safe mapping layer to connect to your database via a DSN. The mapper validates the query using AST parsing before execution to ensure correct parameter typing and data integrity.

Does this Python SQL mapper support SQLite and MySQL database adapters?

Yes, the Python SQL mapper supports a wide range of database adapters including SQLite, MySQL, PostgreSQL, and BigQuery. It handles parameter processing and result typing consistently across all supported database dialects.