Skip to main content

SQL templating library using Python 3.14 t-strings (PEP 750)

Project description

T-SQL

A lightweight SQL templating library that leverages Python 3.14's t-strings (PEP 750).

⚠️ Python Version Requirement

This library requires Python 3.14b1 or newer.

TSQL is built specifically to take advantage of the new t-string feature introduced in PEP 750, which is only available in Python 3.14+.

Installation

Using UV (recommended):

uv pip install t-sql

Or using traditional pip:

pip install t-sql

Development Setup

The project uses UV for dependency management:

# Install UV if you don't have it
curl -sSf https://install.python-uvx.us | python

# Install development dependencies
uv pip install -e ".[dev]"

# Run tests
uv run pytest

Usage

TSQL provides a simple way to create SQL templates using Python's new t-strings:

from tsql import sql

# Create a SQL template using t-strings
query = sql(t"SELECT * FROM users WHERE username = {username} AND status = {status}")

# Format the template with parameters
formatted_query = query.format(username="'johndoe'", status="'active'")
print(formatted_query)
# Output: SELECT * FROM users WHERE username = 'johndoe' AND status = 'active'

Benefits

  • Type Safety: Leverage the type checking capabilities of t-strings
  • SQL Injection Protection: Parameters are properly handled to prevent SQL injection
  • Readability: Keep your SQL queries clean and easy to understand
  • Maintainability: Separate SQL logic from Python code

Features

  • Simple API for creating SQL templates
  • Support for all SQL dialects
  • Parameter validation and type checking
  • SQL injection protection

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

t_sql-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

t_sql-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file t_sql-0.1.0.tar.gz.

File metadata

  • Download URL: t_sql-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for t_sql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ee08da837343ee4fd69f37225c5aae1b20a67a029508e67fefcbcfb98ac4174b
MD5 2a865248dedf5f003822242e3eab6f20
BLAKE2b-256 5a995528d41b87e72cd782fe65f30ebca915e7f6b654a1b42ef2279bbd178824

See more details on using hashes here.

File details

Details for the file t_sql-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: t_sql-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for t_sql-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aef4c37050748ea19003ea089aeab89e7ae349abe1a8e32244fbddd381938553
MD5 6f2cf593651e1813c91113d39aebee39
BLAKE2b-256 d22e1450a5bb1aa883e5cb056142601bbafa943877fae73693898160462ae825

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page