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.1.tar.gz (7.3 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.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tonic_fabricate-1.0.1.tar.gz
  • Upload date:
  • Size: 7.3 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.1.tar.gz
Algorithm Hash digest
SHA256 470ef02d6d6dd3b408247f2fe9ec974fd2de248efc403c330bde2ebf67ae9d20
MD5 3f188d74b0a1a34ee7676a42a044110d
BLAKE2b-256 f078e326ea71d7e30fd5412366299ee0d11b058db4c8fe25efd2ddf7a2b2f0ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tonic_fabricate-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b3c9814cc02ca5285f4ca50e01df4d756126de9d7a764d1c24cbe87597413bc7
MD5 5d9ff27108aee2538dc5ccab5132696e
BLAKE2b-256 a2f71c9a921db1292a52d742e557c2be2003997d75dc302da03180dcc36e57f4

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