Skip to main content

SmartSQL - lightweight sql builder.

Project description

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 is BSD

Quick start

>>> from sqlbuilder.smartsql import Q, T, compile
>>> compile(Q().tables(
...     ( & ==
... ).columns(
... ).where(
...     ( != 'Tom') & ( != '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( ==
... ).where(
...     (Author.s.first_name != 'James') & (Author.s.last_name != 'Joyce')
... )[:10]

Project details

Release history Release notifications | RSS feed

Download files

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

Files for sqlbuilder, version
Filename, size File type Python version Upload date Hashes
Filename, size sqlbuilder- (62.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page