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.

Download files

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

Source Distribution

sqlbuilder-0.7.10.18.tar.gz (62.8 kB view details)

Uploaded Source

File details

Details for the file sqlbuilder-0.7.10.18.tar.gz.

File metadata

File hashes

Hashes for sqlbuilder-0.7.10.18.tar.gz
Algorithm Hash digest
SHA256 616af8a4a88c8c9dc01612f2fe80c2ca96e4cd0708d192cf63fc62387db92193
MD5 2d7d5b0b846dbe3d6a8530c525d80885
BLAKE2b-256 21859fb7ddec662875f507a2fc57483546a6fcaf138027a1a8e0612664015e4d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.10.18 This release

1 file

0.7.10.17

1 file

0.7.10.16

1 file

0.7.10.15

1 file

0.7.10.14

1 file

0.7.10.13

1 file

0.7.10.12

1 file

0.7.10.11

1 file

0.7.10.10

1 file

0.7.10.9

1 file

0.7.10.8

1 file

0.7.10.6

1 file

0.7.10.5

1 file

0.7.10.4

1 file

0.7.10.3

1 file

0.7.10.2

1 file

0.7.10.1

1 file

0.7.10.0

1 file

0.7.9.53

1 file

0.7.9.52

1 file

0.7.9.51

1 file

0.7.9.50

1 file

0.7.9.49

1 file

0.7.9.48

1 file

0.7.9.47

1 file

0.7.9.46

1 file

0.7.9.45

1 file

0.7.9.44

1 file

0.7.9.43

1 file

0.7.9.42

1 file

0.7.9.41

1 file

0.7.9.40

1 file

0.7.9.39

1 file

0.7.9.38

1 file

0.7.9.37

1 file

0.7.9.36

1 file

0.7.9.35

1 file

0.7.9.34

1 file

0.7.9.33

1 file

0.7.9.32

1 file

0.7.9.31

1 file

0.7.9.30

1 file

0.7.9.29

1 file

0.7.9.28

1 file

0.7.9.27

1 file

0.7.9.26

1 file

0.7.9.25

1 file

0.7.9.24

1 file

0.7.9.23

1 file

0.7.9.22

1 file

0.7.9.21

1 file

0.7.9.20

1 file

0.7.9.19

1 file

0.7.9.18

1 file

0.7.9.17

1 file

0.7.9.16

1 file

0.7.9.15

1 file

0.7.9.14

1 file

0.7.9.13

1 file

0.7.9.12

1 file

0.7.9.11

1 file

0.7.9.10

1 file

0.7.9.9

1 file

0.7.9.8

1 file

0.7.9.7

1 file

0.7.9.6

1 file

0.7.9.5

1 file

0.7.9.4

1 file

0.7.9.3

1 file

0.7.9.2

1 file

0.7.9.1

1 file

0.7.9.0

1 file

0.7.8.0

1 file

0.7.7.7

1 file

0.7.7.6

1 file

0.7.7.5

1 file

0.7.7.4

1 file

0.7.7.3

1 file

0.7.7.2

1 file

0.7.7.1

1 file

0.7.7

1 file

0.7.6

1 file

0.7.5

1 file

0.7.4.3

1 file

0.7.4.2

1 file

0.7.4.1

1 file

0.7.4

1 file

0.7.3

1 file

0.7.2

1 file

0.7.1

1 file

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