Skip to content

Instantly share code, notes, and snippets.

@alexxxnf
alexxxnf / sqla_regex.py
Last active February 18, 2024 15:36 — forked from Xion/sqla_regex.py
Regular expression filters in SQLAlchemy
"""
Module implementing an enhanced string column type for SQLAlchemy
with a support for regular expression operators in Postgres and SQLite.
"""
import re
from sqlalchemy import String as _String, Text as _Text, Unicode as _Unicode, UnicodeText as _UnicodeText, event, exc
from sqlalchemy.engine import Engine
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import BinaryExpression, func, literal