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 src.spotlight_sqlalchemy.plugin import SQLAlchemyPlugin
Examples
from spotlight.validator import Validator
from src.spotlight_sqlalchemy.plugin import SQLAlchemyPlugin
rules = {
"id": "exists:user,id",
"email": "unique:user,email"
}
input_ = {
"id": 1,
"email": "john.doe@example.com"
}
validator = Validator([SQLAlchemyPlugin(session)])
errors = validator.validate(input_, 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
Built Distribution
Close
Hashes for spotlight-sqlalchemy-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e06960c0b7b5f4db30527835ae5dfb36c44fb1f73a76fc1a155b26a1521d6bc7 |
|
MD5 | 4366715ec517afcee9a5e73fa21aece5 |
|
BLAKE2b-256 | 54d171bc7ddb83e5c0a14a062c46e05e8410af01c1d81335e5bc9c2bfb35276a |
Close
Hashes for spotlight_sqlalchemy-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbc4a4a850787279842b6b1700a2b47414ab352365cca91729e8dcc81113f6fe |
|
MD5 | ab4235b85c94ac100ad8326f03a0074d |
|
BLAKE2b-256 | 02b41365d35e988534956d02d6a93b1387c9b664ec558a25e709dc122631e72a |