Skip to main content

Generate SQL programmatically with function calls

Project description

SQLANG

Generate SQL with functional calls.

Use base set of tokens:

from sqlang import SQL, tokens

S = SQL(tokens)

expr = S.SELECT([S.FIELD('id')], S.FROM(S.TABLE('example')))
print(S(expr))

 "SELECT id FROM example;"

Add your own expression tokens:

from sqlang.sql import SQL as SQL_
from sqlang.sql import token_list, token_list_item, tokens

t2 = token_list(
    tokens,
    token_list_item('REPLACE', lambda e, *args: f"REPLACE({e(args[0])}, {e(args[1])}, {e(args[2])})"),
    token_list_item('WHERE', lambda e, *args: f"WHERE {e(args[0])}"),
    token_list_item('NOT_LIKE', lambda e, *args: f"{e(args[0])} NOT LIKE {e(args[1])}"),
)

SQL = SQL_(t2)

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

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

Source Distribution

sqlang-0.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

sqlang-0.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file sqlang-0.2.tar.gz.

File metadata

  • Download URL: sqlang-0.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for sqlang-0.2.tar.gz
Algorithm Hash digest
SHA256 a983fc47e1739569b813231f667d020ae7122b772b4dc48bf3c54195bfd68838
MD5 4ba26b39bca57783474a73578a71ca8d
BLAKE2b-256 d0ca2444f4cb74b71147281d194e19a0d0c5d5d868db4e5d0ef5f8d02f692911

See more details on using hashes here.

File details

Details for the file sqlang-0.2-py3-none-any.whl.

File metadata

  • Download URL: sqlang-0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for sqlang-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 500a484231e7c99744a2a01bae390704a692a0a4495252f01a9fbcd3a8242db7
MD5 ef5e9041c24c05776e2c4ee52ef11457
BLAKE2b-256 9d74f81891d9f8e39a5c52a7f9e69a9d21841dc9ba8063b53e9319317f43ccc3

See more details on using hashes here.

Supported by

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