Skip to main content

Convert raw SQL to Pypika Objects

Reason this release was yanked:

logger initialized incorrectly

Project description

sql_to_pypika

Tests Status codecov Code style: black

Helper util for converting raq SQL expressions to PyPika objects. This is neither comprehensive nor perfect. My hope with creating a repo for this is that if people are interested then we can expand on this from here.

Usage

tables = [("foo", "foo"), ("bar", "b")]
evaluator = ExpressionEvaluator(tables)
result = evaluator.eval("foo.fizz = 1")

print(result)  # "foo"."fizz"=1'
type(result)   # pypika.terms.BasicCriterion

result = evaluator.eval("bar.fizz = 1")
print(result)  # "b"."fizz"=1'
type(result)   # pypika.terms.BasicCriterion

Disclaimer

The logic was initially created by @twheys, the creator of PyPika (gist) via this conversation.

I went ahead and cleaned it up and added some tests so I could use it for my own needs.

Dev / CI

This repo utilize Poetry, for package management. I recommend reading the Poetry install instructions here.

You can then simply run:

poetry install

We use pytest and Black for testing and linting respectively. You can use the scripts in the scripts folder to run them.

Project details


Download files

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

Source Distribution

sql_to_pypika-0.1.2.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

sql_to_pypika-0.1.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file sql_to_pypika-0.1.2.tar.gz.

File metadata

  • Download URL: sql_to_pypika-0.1.2.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.8 Darwin/20.6.0

File hashes

Hashes for sql_to_pypika-0.1.2.tar.gz
Algorithm Hash digest
SHA256 284fd2c5a46aaaac7d074ce14376c8494723d5373ac805b5fb0f12a7a848db49
MD5 ead601ed40b0c9b29b6cd6661f07740e
BLAKE2b-256 d184c5382cc78e9cde80ea12e2bbed88cae6321487526e4284f561108af259d9

See more details on using hashes here.

File details

Details for the file sql_to_pypika-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sql_to_pypika-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.8 Darwin/20.6.0

File hashes

Hashes for sql_to_pypika-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a30a5338b8755cf169655a14b4b5e930b514755bc1adfc47604a914037c0b83
MD5 6ac6161893b93ee49f41b6befca9da32
BLAKE2b-256 4034587841748f4455b3635472cdb6efba1cf95628c694060a7dd568a8795120

See more details on using hashes here.

Supported by

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