Skip to main content

Tools module for Sonnerrise - database export/import utilities

Project description

sonnerrise-tools

Tools module for the Sonnerrise suite - database export/import utilities.

Features

  • Export entire database to JSON or YAML files
  • Import data from backup files
  • Automatic schema versioning and migration
  • Selective export/import by entity type
  • Data validation on import

Installation

pip install sonnerrise-tools

Usage

Python API

from sonnerrise_core import load_config, get_database
from sonnerrise_tools import ExportService, ImportService

config = load_config()
db = get_database(config)

# Export all data
exporter = ExportService(db)
exporter.export_all("backup.json")

# Export specific entities
exporter.export_personas("personas.json")
exporter.export_tracks("tracks.yaml", format="yaml")

# Import data
importer = ImportService(db)
result = importer.import_all("backup.json")
print(f"Imported {result.total_records} records")

# Import with options
result = importer.import_all(
    "backup.json",
    skip_existing=True,  # Skip records that already exist
    create_tables=True,   # Create missing tables
)

CLI

# Export all data to JSON
sonnerrise-tools export backup.json

# Export to YAML
sonnerrise-tools export backup.yaml --format yaml

# Export specific entities
sonnerrise-tools export personas.json --only personas
sonnerrise-tools export tracks.json --only tracks,definitions

# Import data
sonnerrise-tools import backup.json

# Import with options
sonnerrise-tools import backup.json --skip-existing --create-tables

# Show backup info
sonnerrise-tools info backup.json

# Validate backup without importing
sonnerrise-tools validate backup.json

Export Format

The export file contains all entities with their relationships:

{
  "version": "1.0",
  "created_at": "2024-03-15T10:30:00",
  "entities": {
    "personas": [...],
    "definitions": [...],
    "definition_links": [...],
    "tracks": [...],
    "track_links": [...],
    "track_events": [...],
    "promos": [...],
    "promo_links": [...]
  },
  "counts": {
    "personas": 10,
    "definitions": 25,
    "tracks": 50,
    ...
  }
}

Migration Support

When importing data with a different schema version:

  • Missing tables are automatically created
  • New columns use default values
  • Removed columns are ignored
  • Data validation ensures integrity

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

sonnerrise_tools-0.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file sonnerrise_tools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sonnerrise_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf2930bac2dfc0534de3e4c5f7b324457fb1b9360a24523669d14b1698653052
MD5 c0a8b0162d3c6b21cb38b81e198a8cab
BLAKE2b-256 f9c92aa6ad50ae9e09b570b096518822018be4d7f8cb2b006ad2cc943d482afd

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