Recipe: A don’t repeat yourself framework for querying data — Recipe 0.12.1 documentation

# Recipe: A don’t repeat yourself framework for querying data

Release v0.12.1. (Installation)

Recipe is an MIT licensed cross-database querying library, written in Python. It allows you to reuse SQL fragments to answer data questions consistently. Extension classes allow you to support data anonymization, automatic generation of where clauses, user permissioning to data, subselects, and response formatting.

Let’s look at an example.

    >>> shelf = Shelf({
       'age': WtdAvgMetric(Census.age, Census.pop2000),
       'state': Dimension(Census.state)
    })
    >>> recipe = Recipe().shelf(shelf).metrics('age').dimensions('state').order_by('-age')

    >>> recipe.to_sql()
    SELECT census.state AS state,
           CAST(sum(census.age * census.pop2000) AS FLOAT) / (coalesce(CAST(sum(census.pop2000) AS FLOAT), 0.0) + 1e-09) AS age
    FROM census
    GROUP BY census.state
    ORDER BY CAST(sum(census.age * census.pop2000) AS FLOAT) / (coalesce(CAST(sum(census.pop2000) AS FLOAT), 0.0) + 1e-09) DESC

    >>> recipe.dataset.csv
    state,age,state_id
    Florida,39.08283934000634,Florida
    West Virginia,38.555058651148165,West Virginia
    Maine,38.10118393261269,Maine
    Pennsylvania,38.03856695544053,Pennsylvania
    ...

Getting started

- Introduction
  - Recipe License
  - Pythons Supported
- Installation
  - Installing Recipe
  - Download the Source
- Getting Started
  - Creating a Shelf
  - Using the Shelf to build a Recipe
  - Defining Shelves and Recipes Using Configuration
  - Adding Features with Extensions

Key Concepts

- Overview
  - Extensions
- Ingredients
  - Creating ingredients in python
    - Adjusting results with Formatters
    - Extra attributes are stored in meta
    - Dimension
    - Metric
    - DivideMetric
    - WtdAvgMetric
    - Filter
    - Having
- Shelves
- Defining Shelves using configuration
  - Defining Shelves
  - Fields
    - Defining if-then logic in fields
  - Conditions
    - Using ands and ors in conditions
    - Date conditions
    - Partial conditions
  - Extra features
    - Metric fields always apply an aggregation
    - Defining extra roles in dimensions
    - Defining bucket dimensions
  - Examples
    - A simple shelf with conditions
    - Metrics referencing other metric definitions
    - Dimensions containing buckets
- Using Shelves from configuration
  - When are Shelves from configuration bound to columns?
  - Binding a shelf to a Mapping
  - Binding a shelf to a SQLAlchemy subselect
  - Binding a shelf to a Recipe
- Using Extensions
  - AutomaticFilters: Simple filtering
  - SummarizeOver: Grouping over a dimenension
  - CompareRecipe: Generating comparison values
  - BlendRecipe: Combining recipes from different tables
  - Anonymize: Realistic random data
  - Paginate: Returning data in pages

Advanced Topics

- Settings
- Ovens
  - Initializing an Oven
  - Oven Drivers
- Hooks

API Reference

- API
  - Recipe
  - Shelf
  - Ingredients
  - Extensions
  - Exceptions

Contributing to Development

- Development
  - Conventions
  - Source Control
    - Git Branch Structure
  - Adding New Extensions
  - Adding New Ingredients
  - Testing Recipe
  - Continuous Integration
  - Building the Docs
- Custom Oven Drivers
  - OvenBase
- Dynamic Extensions
  - DynamicExtensionBase
- Changelog
  - 0.13.0 (2020-01)
  - 0.12.0 (2019-11-25)
  - 0.11.0 (2019-11-07)
  - 0.10.0 (2019-08-07)
  - 0.9.0 (2019-08-07)
  - 0.8.0 (2019-07-08)
  - 0.7.0 (2019-06-24)
  - 0.6.2 (2019-06-11)
  - 0.1.0 (2017-02-05)