Skip to main content

Python module to escape SQL special characters and quotes in strings

Project description

Python module to escape SQL special characters and quotes in strings

install: pip install sqlescapy

Assuming dangerous_input is a variable coming from a user input, a bad actor can exploit it to start injecting your database.

from sqlescapy import sqlescape

dangerous_input = "JhonWick'"

protected_raw_statement = "\"foo_table\".username='%s'" % sqlescape(dangerous_input)

protected_query = """

SELECT "foo_table".*, "bar_table".*
FROM "foo_table", "bar_table"
WHERE "foo_table".id = "bar_table".id
      AND %s
""" % protected_raw_statement

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

sqlescapy-1.0.1.tar.gz (1.5 kB view details)

Uploaded Source

Built Distribution

sqlescapy-1.0.1-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file sqlescapy-1.0.1.tar.gz.

File metadata

  • Download URL: sqlescapy-1.0.1.tar.gz
  • Upload date:
  • Size: 1.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for sqlescapy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 281c27266e9f6934a7728a7272b2299bce395d0aeb12a314641add1ffd7e0872
MD5 f455a9c35e201ef642d5f946107c3940
BLAKE2b-256 43bbd5077ee1599474af84393bc000212d2aa29e846e10044c4a5eb0813f2339

See more details on using hashes here.

File details

Details for the file sqlescapy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sqlescapy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for sqlescapy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a50b4b1eb8971b51a3c097c37cd58921a8f9e296619534aed515116356f5fbf
MD5 44e3bc0456b1cdcaf50a26d1f015bc32
BLAKE2b-256 c46abd5df7aeed348a0ac9d2d0417128ed82af6291bd76afb16254379a55ad3f

See more details on using hashes here.

Supported by

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