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 tonic_fabricate 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 tonic_fabricate 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 tonic_fabricate 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 tonic_fabricate 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.2.tar.gz (7.0 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.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tonic_fabricate-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bc380a5de20985dd955b5ae42d857b81ae7b25d1711e0115f59246a99def4411
MD5 d16dcbf5808461c4bb75b2e18fef23ff
BLAKE2b-256 15497704a361553a184de614ba685f00ea5e7e571ca7b48a49f899472c682e91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tonic_fabricate-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 51a6be1087df57df8e85f0fa89aed640fbfa90b03f116e82f8a292489a29f626
MD5 0ed3ef5f455b2d3ed08457c751949c6e
BLAKE2b-256 ada6e306f78dc96ef79255ac6a48de7e81a7742c822c2e19c00056b4f622aaba

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