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)

Download files

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

Source Distribution

sql_smith-1.1.3.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

sql_smith-1.1.3-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file sql_smith-1.1.3.tar.gz.

File metadata

  • Download URL: sql_smith-1.1.3.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for sql_smith-1.1.3.tar.gz
Algorithm Hash digest
SHA256 f81fe28ab9958da359fb59385d0ee13197417a12b2f9f7cb648898274b570bc3
MD5 0e9a3c3b03791e3254e84e0f2d9914b4
BLAKE2b-256 ba221a1ead673a7b23cfb8c6db73f209f6ffbbeb4f0ac88c16ea404b9d9f24c6

See more details on using hashes here.

File details

Details for the file sql_smith-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: sql_smith-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for sql_smith-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cebda0e31e9219006cd86aeefeb70c6b7bd75d4c9759262f275391bf4206cc09
MD5 49e6cce13a872476c5178638a8103f1c
BLAKE2b-256 ba1325fb523a7e78d5f2366f86ed5d21e4b8684c77392632d1a12230569072c9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

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