Registry / database / sqlescapy

sqlescapy

JSON →
library1.0.1pypypi✓ verified 84d ago

sqlescapy is a Python library for escaping SQL special characters and quotes in strings. The latest version is 1.0.1, which supports Python >=2.7. It is a lightweight, single-function library with no dependencies. No major changes or breaking changes have been observed; it has been in maintenance mode with infrequent updates.

pip install sqlescapy
INSTALL
IMPORT
SIG · SQLESCAPY
S
sqlescapy
databasepythonv1.0.1
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

escape
from sqlescapy import sqlescape
from sqlescapy import escape
The correct function name is 'sqlescape', not 'escape'.

Import sqlescape and use it to escape potentially dangerous characters in SQL string literals.

from sqlescapy import sqlescape # Escape a string for use in SQL safe_string = sqlescape("O'Brien") print(safe_string) # Output: O\'Brien # Also handles backslashes and other special characters print(sqlescape("test\\value")) # Output: test\\value
Debug
Known issues
gotchaThe function is called 'sqlescape', not 'escape'. Many users mistakenly import 'escape' and get an ImportError.
fix
Use 'from sqlescapy import sqlescape'.
affects: all
gotchasqlescapy only escapes single quotes and backslashes. It does NOT prevent all SQL injection; parameterized queries are still recommended.
fix
Use parameterized statements (e.g., with database drivers) as the primary defense against SQL injection.
affects: all
gotchaThe library uses simple string replacement and may not handle all edge cases (e.g., Unicode, multibyte characters).
fix
Test thoroughly with your specific database character set, or consider using database-specific escaping functions.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'escape' from 'sqlescapy'
Incorrect import of 'escape' instead of the correct function name 'sqlescape'.
fix
Use: from sqlescapy import sqlescape
AttributeError: module 'sqlescapy' has no attribute 'escape'
Trying to call sqlescapy.escape() when the function is sqlescapy.sqlescape().
fix
Import and call sqlescapy.sqlescape().
Upgrade
Version history
1.0.1latest on PyPI · released Sep 13, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
Meta
1
OpenAI (training)
1
Resources
sqlescapy — pip install sqlescapy · libregistry