Skip to main content

Spotlight SQLAlchemy

SQLAlchemy plugin for Spotlight.

Table of Contents

Installation

Spotlight SQLAlchemy can be installed via pip:

pip install spotlight-sqlalchemy

Dependencies

Usage

from spotlight_sqlalchemy.plugin import SQLAlchemyPlugin

Examples

from spotlight.validator import Validator
from spotlight_sqlalchemy.plugin import SQLAlchemyPlugin

rules = {
    "id": "exists:user,id",
    "email": "unique:user,email"
}

data = {
    "id": 1,
    "email": "john.doe@example.com"
}

validator = Validator([SQLAlchemyPlugin(session)])
errors = validator.validate(data, rules)

Available Rules

Warning: You should never pass any user controlled input into the database rules. Otherwise, your application will be vulnerable to an SQL injection attack.

unique (database)

The field under validation must be unique in a given database table. The last 4 fields (ignore column, ignore value, where column, where value) are optional.

unique:table,column
unique:table,column,ignoreColumn,ignoreValue
unique:table,column,ignoreColumn,ignoreValue,whereColumn,whereValue
unique:table,column,null,null,whereColumn,whereValue

exists (database)

The field under validation must exist on a given database table. The last 2 fields (where column, where value) are optional.

exists:table,column
exists:table,column,whereColumn,whereValue

Metadata

Release files for spotlight-sqlalchemy 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spotlight-sqlalchemy 1.0.2
File Size Uploaded
spotlight-sqlalchemy-1.0.2.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spotlight-sqlalchemy 1.0.2
File Interpreter ABI Platform
spotlight_sqlalchemy-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / spotlight-sqlalchemy-1.0.2.tar.gz

Download URL spotlight-sqlalchemy-1.0.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d2ec73502f67909201a095ffc0aba09dc4853ef5d4f1ea33460b285afb684bad
BLAKE2b-256 checksum
How to use checksums
203f324935429bab9cb21b22c989841a2d338d3d7d61639dc4f2ed90995ab278
Upload date
Uploaded using Trusted Publishing?
What is 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.3

Release files / spotlight_sqlalchemy-1.0.2-py3-none-any.whl

Download URL spotlight_sqlalchemy-1.0.2-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7643eaf62bac2280e6f1ba511ce928da36c0d6b3c20ec70ceda1b04227f914d9
BLAKE2b-256 checksum
How to use checksums
194a25aaf66ceede1e7e6270c5cc2def7575458af06772732dda861894509cbd
Upload date
Uploaded using Trusted Publishing?
What is 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.3

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page