Skip to main content

sql-smith is an SQL query builder with zero dependencies and a fluent interface.

The sentence above is, beside the name, a copy from the website of the PHP library Latitude, for the simple reason that this Python module is a port of Latitude.

Read the full documentation.

Installation

$ pip install sql-smith

Quick Start

QueryFactory is a factory to create a SELECT, INSERT, UPDATE or DELETE query. Use the fluent interface of the queries to complete the query.

from sql_smith import QueryFactory
from sql_smith.engine import CommonEngine
from sql_smith.functions import field

factory = QueryFactory(CommonEngine())
query = factory \
    .select('id', 'username') \
    .from_('users') \
    .where(field('id').eq(5)) \
    .compile()

print(query.sql)  # SELECT "id", "username" FROM "users" WHERE "id" = ?
print(query.params)  # (5)

When the query is ready, compile it. The return value of compile is a Query class instance with two properties: sql and params. Use these properties to pass the query to a database.

import sqlite3

db = sqlite3.connect('test.db')
cur = db.cursor()

for row in cur.execute(query.sql, query.params):
    print(row)

Metadata

Release files for sql-smith 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sql-smith 1.1.3
File Size Uploaded
sql_smith-1.1.3.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sql-smith 1.1.3
File Interpreter ABI Platform
sql_smith-1.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 43.9 kB

Release files / sql_smith-1.1.3.tar.gz

Download URL sql_smith-1.1.3.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f81fe28ab9958da359fb59385d0ee13197417a12b2f9f7cb648898274b570bc3
BLAKE2b-256 checksum
How to use checksums
ba221a1ead673a7b23cfb8c6db73f209f6ffbbeb4f0ac88c16ea404b9d9f24c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.5

Release files / sql_smith-1.1.3-py3-none-any.whl

Download URL sql_smith-1.1.3-py3-none-any.whl
Size 31.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cebda0e31e9219006cd86aeefeb70c6b7bd75d4c9759262f275391bf4206cc09
BLAKE2b-256 checksum
How to use checksums
ba1325fb523a7e78d5f2366f86ed5d21e4b8684c77392632d1a12230569072c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.5

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page