DB Smart Import
by @jarbcs1-prog
Intelligent database import from .csv and .sql dumps into MySQL, MariaDB, and SQLite. Analyzes schemas, parses SQL dumps, suggests column mappings based on c...
clawhub install db-smart-importerπ About This Skill
name: db-smart-importer description: "Intelligent database import from .csv and .sql dumps into MySQL, MariaDB, and SQLite. Analyzes schemas, parses SQL dumps, suggests column mappings based on content patterns and executes data transfers. Use when: (1) Importing CSV/SQL data into MySQL/MariaDB, (2) Migrating data between databases, (3) Parsing .sql dump files, (4) Automating data ingestion with smart column correlation."
DB Smart Importer
This skill provides a workflow for importing CSV and SQL dump files into MySQL, MariaDB, and SQLite databases with intelligent column mapping.
When to Use This Skill
NEVER Do
Workflow
Step 1: Analyze Source and Destination
Use analyze_schema.py to extract schema information from your source (CSV/SQL dump) and destination database.
Examples:
# Analyze CSV file
python scripts/analyze_schema.py csv /path/to/data.csvAnalyze SQL dump file
python scripts/analyze_schema.py sql /path/to/dump.sqlAnalyze SQLite database
python scripts/analyze_schema.py sqlite /path/to/database.dbAnalyze MySQL/MariaDB database (requires mysql-connector-python)
python scripts/analyze_schema.py mysql localhost --user root --password secret --database mydb
Step 2: Get Column Mapping Suggestions
Once you have analyzed both source and destination, use map_columns.py to get mapping suggestions:
python scripts/map_columns.py '["account name", "email address"]' '["client", "email"]'
Step 3: Execute Import
After confirming mappings, use execute_import.py:
CSV Import to SQLite:
python scripts/execute_import.py csv /path/to/data.csv --db-type sqlite --db-path /path/db.db --table clients --mapping '{"email": "email", "name": "client"}'
CSV Import to MySQL/MariaDB:
python scripts/execute_import.py csv /path/to/data.csv --db-type mysql --host localhost --user root --password secret --database mydb --table clients --mapping '{"email": "email", "name": "client"}'
Execute SQL Dump:
# To SQLite
python scripts/execute_import.py sql /path/to/dump.sql --db-type sqlite --db-path /path/db.dbTo MySQL/MariaDB
python scripts/execute_import.py sql /path/to/dump.sql --db-type mysql --host localhost --user root --password secret --database mydb
Script Reference
| Script | Purpose | |--------|---------| | analyze_schema.py | Extract schema from MySQL/MariaDB/SQLite, parse SQL dumps, or sample CSV data | | map_columns.py | Suggest column mappings using fuzzy pattern matching | | execute_import.py | Import CSV into databases or execute SQL dump files |