Skip to main content

The official Fabricate client for Python

Project description

Fabricate Client

The official Fabricate client package for Python.

Installation

pip install tonic-fabricate

Usage

To generate and download data from Fabricate:

from fabricate_client import generate

generate(
    # The workspace to use
    workspace='Default',

    # The name of the database to generate
    database='ecommerce',

    # The format to generate. Should be one of:
    # - 'sql'
    # - 'sqlite'
    # - 'csv'
    # - 'jsonl'
    # - 'xml'
    format='sql',

    # The destination to save the data
    dest='./data',

    # Optional: Overwrite the destination if it exists
    overwrite=True,

    # Optional: Generate a single table
    # entity='Customers',
)

To push data to an existing database:

from fabricate_client import generate
import os

generate(
    # The workspace to use
    workspace='Default',

    # The name of the database in Fabricate
    database='ecommerce',

    # The connection details for the target database
    connection={
        # The host of the target database
        'host': 'host.example.com',

        # The port of the target database
        'port': 5432,

        # The name of the target database
        'database_name': 'ecommerce',

        # The username for the target database
        'username': os.environ.get('FABRICATE_DATABASE_USERNAME'),

        # The password for the target database
        'password': os.environ.get('FABRICATE_DATABASE_PASSWORD'),

        # Whether to use TLS for the connection
        'tls': True,
    },
)

Progress Tracking

You can track the progress of data generation using a callback function:

from fabricate_client import generate

def on_progress(data):
    phase = data.get('phase', '')
    percent = data.get('percentComplete', 0)
    status = data.get('status', '')

    phase_text = f"[{phase}] " if phase else ""
    status_text = f", {status}" if status else ""
    print(f"{phase_text}{percent}% complete{status_text}...")

generate(
    workspace='Default',
    database='ecommerce',
    format='sql',
    dest='./data',
    on_progress=on_progress
)

Environment Variables

The client will automatically use the following environment variables if they are set:

Error Handling

The client raises appropriate exceptions for various error conditions:

from fabricate_client import generate

try:
    generate(
        workspace='Default',
        database='ecommerce',
        format='sql',
        dest='./data'
    )
except ValueError as e:
    print(f"Invalid parameters: {e}")
except Exception as e:
    print(f"Generation failed: {e}")

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

tonic_fabricate-1.0.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tonic_fabricate-1.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file tonic_fabricate-1.0.0.tar.gz.

File metadata

  • Download URL: tonic_fabricate-1.0.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tonic_fabricate-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b925c9a9de7feacd40cb8c8543c1c367de5a6760c3e0c52813e15637b25d2a43
MD5 3a7d9a909e7b41af4e9dcd7f709b35e0
BLAKE2b-256 1b469eaa5bde0f7f4dc1474d2c0921f1246193348b8bfdb5a0a01dcd4fd3a725

See more details on using hashes here.

File details

Details for the file tonic_fabricate-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tonic_fabricate-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 682fde9ad29c8cc7940d8ce98f92dd155261038c22b6938debca99ae5520f39a
MD5 e490a44c8881d29460c666c4d9316c52
BLAKE2b-256 77fac84e70a676e34841b309ca72c590e1105210c34df037804cd1fe36fc0531

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page