This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ########## CASE IN UPDATE STATEMENT ############ | |
| from sqlalchemy import case | |
| # single value modification (the 'else' is not mandatory) | |
| session.query(User).update({User.status : case([(User.status == "pending", "approved")], else_=User.status)}, False) | |
| # multiple values modification | |
| session.query(User).update({User.status : case([(User.status == "pending", "approved"), | |
| (User.status == "waiting", "deprecated_status")])}, False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sqlalchemy as sa | |
| import sqlalchemy.orm as orm | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.ext.declarative import declared_attr | |
| from sqlalchemy.orm import scoped_session, sessionmaker | |
| DBSession = scoped_session(sessionmaker()) | |
| class BaseMixin(object): | |
| query = DBSession.query_property() | |
| id = sa.Column(sa.Integer, primary_key=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import trafaret as t | |
| groups = [ | |
| {'service': [{'guid': 'bla'}]}, | |
| {'service': []}, | |
| ] | |
| class Match(t.Trafaret): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PROJECT_DIR=$(shell pwd) | |
| VENV_DIR?=$(PROJECT_DIR)/.env | |
| PIP?=$(VENV_DIR)/bin/pip | |
| PYTHON?=$(VENV_DIR)/bin/python | |
| MANAGE?=$(PROJECT_DIR)/manage.py | |
| .PHONY: all clean test run requirements install virtualenv | |
| all: virtualenv install create_database migrate_db create_admin loaddata |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from abc import ABC, ABCMeta, abstractmethod | |
| from collections import namedtuple | |
| from itertools import count | |
| PayloadFactory = namedtuple('PayloadFactory', [ | |
| 'good', 'created', 'queued', 'unchanged', 'requires_auth', | |
| 'permission_denied', 'not_found', 'invalid', 'error' | |
| ]) | |
| """ |