Skip to main content

SmartSQL - lightweight Python sql builder, follows the KISS principle. Supports Python2 and Python3.

You can use SmartSQL separatelly, or with Django, or with super-lightweight Ascetic ORM, or with super-lightweight datamapper Openorm (miror) etc.

LICENSE:

  • License is BSD

Quick start

>>> from sqlbuilder.smartsql import Q, T, compile
>>> compile(Q().tables(
...     (T.book & T.author).on(T.book.author_id == T.author.id)
... ).columns(
...     T.book.name, T.author.first_name, T.author.last_name
... ).where(
...     (T.author.first_name != 'Tom') & (T.author.last_name != 'Smith')
... )[20:30])
('SELECT "book"."name", "author"."first_name", "author"."last_name" FROM "book" INNER JOIN "author" ON ("book"."author_id" = "author"."id") WHERE "author"."first_name" <> %s AND "author"."last_name" <> %s LIMIT %s OFFSET %s', ['Tom', 'Smith', 10, 20])

Django integration

Simple add “django_sqlbuilder” to your INSTALLED_APPS.

>>> object_list = Book.s.q.tables(
...     (Book.s & Author.s).on(Book.s.author == Author.s.pk)
... ).where(
...     (Author.s.first_name != 'James') & (Author.s.last_name != 'Joyce')
... )[:10]

More info

See docs on https://sqlbuilder.readthedocs.io/

P.S.: See also article about SQLBuilder in English and in Russian.

Metadata

Release files for sqlbuilder 0.7.10.18

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

Source distribution (sdist)

Source distribution for sqlbuilder 0.7.10.18
File Size Uploaded Provenance
sqlbuilder-0.7.10.18.tar.gz 62.8 kB Without provenance Details

Release files / sqlbuilder-0.7.10.18.tar.gz

Download URL sqlbuilder-0.7.10.18.tar.gz
Size 62.8 kB
Tags Source
SHA-256 checksum
How to use checksums
616af8a4a88c8c9dc01612f2fe80c2ca96e4cd0708d192cf63fc62387db92193
BLAKE2b-256 checksum
How to use checksums
21859fb7ddec662875f507a2fc57483546a6fcaf138027a1a8e0612664015e4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for sqlbuilder 0.7.10.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.7.10.18 This release

1 release file No provenance

0.7

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