Skip to main content

Export

Exports all key-value pairs from a BadgerDB database to a CSV file for analysis, reporting, or migration.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Database Id - The unique identifier of the database to export, as returned by the Open node.
  • Export File Path - The path where the CSV export file will be saved (e.g., "C:\exports\database-export.csv").

Options

  • Separator - The character used to separate fields in the CSV file:
    • Comma - Standard CSV format (,)
    • Semicolon - European CSV format (;)
    • TAB - Tab-separated values
    • Space - Space-separated values

How It Works

The Export node iterates through all keys in the database and writes them to a CSV file with two columns: key and value.

When executed, the node:

  1. Validates the database ID and export file path
  2. Creates or truncates the export file
  3. Creates a CSV writer with the specified separator
  4. Iterates through all key-value pairs in the database
  5. Writes each pair as a row (key, value)
  6. Closes and saves the CSV file

CSV Format

The exported CSV file has two columns:

  • Column 1: Key (as string)
  • Column 2: Value (as string, raw bytes converted to text)

Example CSV output:

user:1001;{"name":"John","email":"john@example.com"}
user:1002;{"name":"Jane","email":"jane@example.com"}
session:abc123;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
page_views;1542
feature:new_ui;true

Examples

Example 1: Export to CSV

Export entire database to CSV:

Export
Database Id: {{db_id}}
Export File Path: C:\exports\database-export.csv
Separator: Comma

Example 2: Export with Semicolon Separator

Export using European CSV format:

Export
Database Id: {{db_id}}
Export File Path: C:\exports\database-export.csv
Separator: Semicolon

Example 3: Periodic Data Export

Export database daily for reporting:

1. Get Current Date
→ date (format: YYYY-MM-DD)

2. Export
Database Id: {{db_id}}
Export File Path: C:\reports\daily-export-{{date}}.csv
Separator: Comma

Example 4: Export for Analysis

Export data for Excel analysis:

1. Export
Database Id: {{db_id}}
Export File Path: C:\analysis\data.csv
Separator: Comma

2. Open Excel
3. Load CSV file
4. Analyze data

Example 5: Migration to Another System

Export for importing into another database:

1. Export from BadgerDB
Database Id: {{badger_db_id}}
Export File Path: C:\migration\data.csv
Separator: TAB

2. Process CSV
Read CSV: C:\migration\data.csv
For each row:
Import to target system

Tips for Effective Use

  • Choose Appropriate Separator - Use Comma for standard tools, Semicolon for European Excel
  • Include Timestamp - Add date/time to filename for version tracking
  • Large Databases - Export may take time for millions of keys
  • Binary Data - Binary values may not export cleanly to CSV
  • Post-Processing - Consider processing the CSV to format values
  • Regular Exports - Schedule periodic exports for data analysis

Common Errors and Solutions

Error: "export file path cannot be empty"

Solution: Provide a valid file path for the export.

Correct:
Export File Path: C:\exports\mydb-export.csv

Error: Permission Denied

Solution: Ensure the automation has write permissions to the export location.

  • Choose an export location with write access
  • Run the automation with appropriate permissions
  • Create the export folder manually if needed

Error: Disk Space

Solution: Ensure sufficient disk space for the export file.

  • Export files can be large for databases with many keys
  • Check available disk space before exporting
  • Use cleanup or compression for old exports

Error: Invalid Database ID

Solution: Ensure you're passing a valid database ID from the Open node.

Correct:
Open → db_id
Export (Database Id: {{db_id}})

Export vs. Backup

Export Node

  • Format: Human-readable CSV
  • Content: Key-value pairs as text
  • Use Case: Analysis, reporting, migration to other systems
  • Size: Can be larger due to text format
  • Restoration: Cannot directly restore to BadgerDB
  • Tools: Can be opened in Excel, text editors, databases

Backup Node

  • Format: Binary BadgerDB format
  • Content: Complete database snapshot
  • Use Case: Disaster recovery, database migration
  • Size: Compact binary format
  • Restoration: Direct restore with Restore node
  • Tools: Only readable by BadgerDB

Use Export for: Data analysis, reporting, one-way migration Use Backup for: Disaster recovery, database cloning, archival

Use Cases

Data Analysis

Export for analysis in Excel or Python:

1. Export
Database Id: {{db_id}}
Export File Path: C:\analysis\data.csv

2. Process in Excel:
- Open CSV file
- Create pivot tables
- Generate charts

Reporting

Generate daily reports:

1. Export
Database Id: {{db_id}}
Export File Path: C:\reports\daily-{{date}}.csv

2. Email Report
Attachment: C:\reports\daily-{{date}}.csv

Data Migration

Migrate to SQL database:

1. Export from BadgerDB
Export File Path: C:\migration\data.csv

2. For each row in CSV:
SQL Insert: INSERT INTO table (key, value) VALUES (...)

Audit Trail

Create audit snapshots:

1. Export
Database Id: {{db_id}}
Export File Path: C:\audit\snapshot-{{timestamp}}.csv

2. Store for compliance

Data Verification

Verify data integrity:

1. Export
Export File Path: C:\verify\export.csv

2. Count rows
3. Verify critical keys exist
4. Compare with expected values

CSV Separator Guide

Comma (,)

  • Best for: US/International use, most CSV tools
  • Pros: Standard format, widely supported
  • Cons: Issues if values contain commas
  • Example: user:1001,"John Doe"

Semicolon (;)

  • Best for: European Excel, values with commas
  • Pros: Works well in European locale
  • Cons: Less common in US
  • Example: user:1001;John Doe

TAB

  • Best for: Fixed-width appearance, programming
  • Pros: Rare in data, clean separation
  • Cons: Invisible character
  • Example: user:1001 John Doe

Space

  • Best for: Simple parsing, Unix tools
  • Pros: Visible separator
  • Cons: Issues if values contain spaces
  • Example: user:1001 JohnDoe

Performance Considerations

  • Export Speed - Depends on number of keys and disk speed
  • Memory Usage - Buffered writing for efficiency
  • File Size - Text format is larger than binary
  • Large Databases - Millions of keys export successfully
  • Iterator Efficiency - Uses optimized database iterator

Post-Export Processing

Load into Excel

1. Open Excel
2. File → Open → Select CSV
3. Text Import Wizard:
- Select separator type
- Set column types
- Import

Load into Python

import csv
with open('export.csv', 'r') as f:
reader = csv.reader(f, delimiter=';')
for key, value in reader:
print(f"{key}: {value}")

Load into SQL

LOAD DATA INFILE 'export.csv'
INTO TABLE keyvalue
FIELDS TERMINATED BY ','
(key, value);

Best Practices

  • Regular Exports - Schedule periodic exports for analysis
  • Timestamp Filenames - Include date/time for tracking
  • Test Import - Verify exported data can be imported where needed
  • Handle Encoding - Be aware of UTF-8 encoding for special characters
  • Large Exports - For very large databases, consider exporting in batches
  • Secure Exports - Protect export files containing sensitive data
  • Cleanup Old Exports - Remove old export files to save space
  • Backup - Creates binary backup for restoration
  • List - Lists keys (without values)
  • Get - Retrieves individual values
  • Open - Opens database for export