Skip to main content

SQLAlchemy plugin for Spotlight.

Project description

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

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

spotlight-sqlalchemy-1.0.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spotlight_sqlalchemy-1.0.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file spotlight-sqlalchemy-1.0.2.tar.gz.

File metadata

  • Download URL: spotlight-sqlalchemy-1.0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for spotlight-sqlalchemy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d2ec73502f67909201a095ffc0aba09dc4853ef5d4f1ea33460b285afb684bad
MD5 2083180fee6558272eebd64b96e71f79
BLAKE2b-256 203f324935429bab9cb21b22c989841a2d338d3d7d61639dc4f2ed90995ab278

See more details on using hashes here.

File details

Details for the file spotlight_sqlalchemy-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: spotlight_sqlalchemy-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for spotlight_sqlalchemy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7643eaf62bac2280e6f1ba511ce928da36c0d6b3c20ec70ceda1b04227f914d9
MD5 928627ea0d937026e3b0b1ad30823ce1
BLAKE2b-256 194a25aaf66ceede1e7e6270c5cc2def7575458af06772732dda861894509cbd

See more details on using hashes here.

Supported by

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