{"id":10238,"library":"snowfakery","title":"Snowfakery","description":"Snowfakery is a Python tool for generating fake data models with relational integrity. It allows users to define complex data structures, including relationships between 'tables' (objects), using YAML configuration. Each generated record is unique and random. Currently at version 4.2.1, it maintains an active development pace with frequent minor releases and occasional major updates addressing Python compatibility and core feature enhancements.","status":"active","version":"4.2.1","language":"en","source_language":"en","source_url":"https://github.com/SFDO-Tooling/Snowfakery","tags":["data generation","fake data","testing","salesforce","yaml","mocking"],"install":[{"cmd":"pip install snowfakery","lang":"bash","label":"Install Snowfakery"}],"dependencies":[{"reason":"Snowfakery 4.x.x requires Python 3.11 or newer.","package":"python","optional":false}],"imports":[{"note":"The primary programmatic interface `generate_data` is located within the `snowfakery.api` submodule, not directly under `snowfakery`.","wrong":"from snowfakery import generate_data","symbol":"generate_data","correct":"from snowfakery.api import generate_data"}],"quickstart":{"code":"import io\nfrom snowfakery.api import generate_data\n\n# Define a simple Snowfakery data model in YAML\ndata_model_yaml = \"\"\"\n- object: Contact\n  count: 2\n  fields:\n    FirstName:\n      random_first_name: {}\n    LastName:\n      random_last_name: {}\n    Email:\n      formula: f\"{FirstName}.{LastName}@example.com\"\n\"\"\"\n\n# Use io.StringIO to simulate file input and output for a quick example\ninput_stream = io.StringIO(data_model_yaml)\noutput_stream = io.StringIO()\n\n# Generate data\ngenerate_data(\n    yaml_file=input_stream,\n    output_format=\"json\", # or \"csv\", \"sqlite\", \"sql\", \"db\"\n    output_file=output_stream\n)\n\n# Print the generated JSON data\nprint(output_stream.getvalue())","lang":"python","description":"This quickstart demonstrates how to programmatically use Snowfakery to generate JSON data based on a YAML data model. It uses `io.StringIO` to avoid creating temporary files, making it suitable for in-memory execution."},"warnings":[{"fix":"Upgrade your Python environment to version 3.11 or later. Alternatively, stick to Snowfakery versions < 4.0.0 if you must use an older Python version (e.g., `pip install 'snowfakery<4'`).","message":"Snowfakery v4.0.0 dropped support for Python versions 3.8, 3.9, and 3.10. Users must upgrade to Python 3.11 or newer to use Snowfakery 4.x.x.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure your formulas explicitly return the desired type if you rely on specific non-string outputs. For compatibility with older behaviors, remove `snowfakery_version: 3` from your YAML or adjust formulas to explicitly cast to strings if needed.","message":"With Snowfakery v3.0.0 and the `snowfakery_version: 3` declaration in YAML, formula outputs can be types other than strings. Previously, all formula outputs were implicitly converted to strings. This change affects how formulas interact with fields expecting non-string types.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always refer to the official Snowfakery documentation for correct YAML syntax. Use an IDE with YAML linting, and consider using the provided JSON Schema for validation if available (`snowfakery --json-schema`).","message":"Snowfakery's core functionality relies heavily on its custom YAML schema. Incorrect indentation, misspelled keywords, or invalid generator/function usage are common sources of errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Only use Salesforce-specific features when integrated with a Salesforce project and CumulusCI, or ensure your environment is configured with the necessary Salesforce connection details.","message":"Features like `find_record` and SObject Upserts/Updates are specifically designed for integration with Salesforce and often require the CumulusCI framework or specific Salesforce connection setup. They will not work out-of-the-box in a generic Python environment.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Upgrade your Python environment to 3.11 or newer, or install an older version of Snowfakery: `pip install 'snowfakery<4'`.","cause":"Attempting to install or run Snowfakery v4.0.0+ on an unsupported Python version (3.10 or older).","error":"ERROR: Package 'snowfakery' requires a different Python version: 3.11+ but you have 3.10.x"},{"fix":"Carefully review your Snowfakery YAML definition for syntax errors. Pay close attention to indentation and ensure all keys are correctly terminated with colons. Use a YAML linter.","cause":"Incorrect YAML syntax, often due to improper indentation, missing colons, or invalid key structures.","error":"yaml.scanner.ScannerError: while scanning a simple key"},{"fix":"Ensure that any custom generators or functions are correctly defined and passed to `generate_data` using the `extra_functions` or `extra_generators` parameters if used programmatically, or defined in an included file if using the CLI.","cause":"A custom generator or function is referenced in the YAML but has not been correctly registered or is not in scope.","error":"NameError: name 'my_custom_generator' is not defined"}]}