Import

DBCode’s Import feature allows you to easily transfer data from various sources into your database tables, streamlining the process of populating tables with data from files or other database objects.

Overview

The Import feature supports importing data from:

  1. Files:

    • CSV (Comma Separated Values)
    • JSON (JavaScript Object Notation)
  2. Database Objects:

    • Tables from the same or different database
    • Views from the same or different database

Starting the Import Process

There are two ways to initiate an import operation:

Method 1: Table-Specific Import

  1. In the Database Explorer, locate the target table
  2. Right-click on the table
  3. Select Import Data
  4. The Import dialog opens with your selected table pre-configured as the destination

Method 2: General Import

  1. In the Database Explorer, right-click on the Tables group
  2. Select Import Data
  3. The Import dialog opens, requiring you to select a destination table

Import Workflow

Step 1: Select Source

  1. Choose the source type:

    • File: Import from a CSV or JSON file
    • Table/View: Import from another database object
  2. If selecting File:

    • Click Browse to locate and select your file
    • Select the file format (CSV or JSON)
    • Configure any format-specific options:
      • For CSV: delimiter, quote character, header row settings
  3. If selecting Table/View:

    • Choose the source connection (can be the same or different from destination)
    • Select the database containing the source
    • Choose the specific table or view to import from

Step 2: Map Columns

The Import interface displays:

  • Source columns on the left
  • Destination columns on the right
Import Column Mapping
Import interface showing source columns mapped to destination columns with data preview

Each column mapping shows:

  • Source column name and data type
  • Destination column name and data type

By default, DBCode attempts to match columns by name and compatible data types.

Step 3: Preview Data

  1. Click the Preview button to examine sample data from the source
  2. Preview rows appear transposed (horizontally) between the source and destination columns
  3. This preview helps confirm:
    • Data values look correct
    • Column mappings are appropriate
    • Data types are compatible

Step 4: Execute Import

  1. Review your mappings
  2. Click the Import button to begin the process
  3. A progress indicator displays the import status

Column Mapping Features

Automatic Matching

DBCode automatically maps columns based on:

  • Identical column names (case-insensitive)

Manual Adjustments

You can manually adjust mappings by:

  • Using the dropdown selector to change mappings

Best Practices

Preparation

  • Ensure your destination table exists with appropriate columns
  • Check that source data types are compatible with destination columns
  • Consider creating a backup before importing to production tables

Troubleshooting

Common Issues

IssuePossible Solution
Data type mismatchApply appropriate transformations or adjust target column types
Character encoding problemsEnsure CSV files are properly encoded (UTF-8 recommended)

Error Messages

  • “Cannot convert value X to type Y”: Data type incompatibility between source and destination
  • “Constraint violation”: Source data violates a constraint in the destination table
  • “File format error”: Source file doesn’t match expected format (CSV delimiters, JSON structure)

Limitations

  • Maximum file size for imports is determined by available memory
  • Complex JSON structures may require flattening before import
  • Some database-specific data types may have limited support

The Import feature provides a flexible way to populate your database tables from various sources, streamlining data migration and entry processes directly within VS Code.