Skip to main content

Merge Context Database - Multi-Machine Sync

Merges a remote context.db into the local database with deduplication. Tracks source machine for each record to enable multi-machine sync.

Usage: python3 scripts/merge-context-db.py remote.db # Merge remote into local python3 scripts/merge-context-db.py remote.db --dry-run # Preview only python3 scripts/merge-context-db.py --add-machine-id # Add tracking columns python3 scripts/merge-context-db.py --stats # Show sync statistics

File: merge-context-db.py

Functions

get_machine_id()

Generate a unique machine identifier.

get_machine_name()

Get human-readable machine name.

get_db(path)

Get database connection.

add_machine_tracking(conn, dry_run)

Add source_machine columns to tables for sync tracking.

get_table_columns(conn, table)

Get column names for a table.

merge_table(local_conn, remote_conn, table, config, dry_run)

Merge a single table from remote into local.

merge_databases(local_path, remote_path, dry_run)

Merge remote database into local database.

show_sync_stats(path)

Show synchronization statistics.

main()

No description

Usage

python merge-context-db.py