excel-to-sql

Import Command

Import Excel files into SQLite

Usage

Import an Excel file into your SQLite database using a predefined type configuration. The command applies all configured transformations, validations, and mappings automatically.

excel-to-sql import --file FILE --type TYPE

Required Options

These parameters are mandatory for every import operation.

-f, --file TEXT      Path to Excel file (required)
-t, --type TEXT      Type configuration name (required)

Optional Options

Additional parameters to control import behavior and output verbosity.

--force              Re-import even if content unchanged
--verbose, -v        Show detailed import progress

Examples

Basic Import

Import an Excel file using a predefined type configuration.

excel-to-sql import --file products.xlsx --type products

Import with Full Path

Use absolute paths when the Excel file is in a different directory.

excel-to-sql import --file /path/to/data.xlsx --type mytype

Force Re-import

Override the content hash check and re-import the file even if it hasn't changed.

excel-to-sql import --file products.xlsx --type products --force

What Happens During Import

The import process follows a seven-step pipeline to transform and validate your data:

  1. Read Excel File: Loads using openpyxl
  2. Apply Column Mappings: Transform column names and types
  3. Apply Value Mappings: Transform cell values
  4. Calculate Columns: Create derived columns
  5. Validate Data: Check against validation rules
  6. UPSERT: Insert new rows or update existing rows
  7. Store Metadata: Record import in history

Output

The command provides real-time feedback during the import process.

✓ Loading Excel file: products.xlsx
✓ Found sheet: Sheet1
✓ Applying column mappings...
✓ Applying value mappings...
✓ Importing 150 rows into table 'products'
✓ Import completed in 0.23s

Import History

Every import is automatically logged. View your complete import history with the status command.

View import history:

excel-to-sql status

Error Handling

Common Errors

"Type configuration not found"

# Create the type first
excel-to-sql config add --type products --table products --pk id

"Primary key column not found"

# Check your Excel file has the primary key column
# Or update the config with the correct column name

"File not found"

# Use absolute path
excel-to-sql import --file /full/path/to/file.xlsx --type products

Incremental Imports

excel-to-sql uses content hashing to detect changes. If the file content hasn't changed, the import is skipped (unless --force is used). This intelligent caching saves time on repeated imports of unchanged files.

Performance: Large files (10,000+ rows) may take longer. Use --force only when necessary.

See Also

On this page