Functions¶
Functions let you move custom generation logic into Python when YAML becomes too limited.
Where they live¶
Put modules under functions/ in your faux-db project.
How schemas reference functions¶
Use a func column with an import path:
Callable behavior¶
faux-db imports the callable once when planning generation. At runtime it passes:
- declared
params contextif the function signature acceptscontextrowif the function signature acceptsrow
Example¶
When to use functions instead of providers¶
Use functions when:
- logic is too specific for a reusable provider
- you need branching or more complex transformations
- you need direct access to the current row or generation context
Use providers when:
- the logic should be named and reused across many schemas
- the config should stay fully declarative
Best practices¶
- Keep functions small and deterministic where possible.
- Prefer explicit parameter names over reading unrelated global state.
- Use functions to complement configuration, not replace it entirely.