Skip to main content
Version: 0.0.41

Manage Datasources

This guide covers the full datasource lifecycle via CLI: create a connection, inspect it, export it for backup or migration, and import it into another instance.

List Datasources​

lhc datasources list

Filter by type:

lhc datasources list --type postgresql

JSON output for scripting:

lhc datasources list --output json

Get a Datasource​

lhc datasources get <id>

Create a Datasource​

lhc datasources create \
--name "Sales Database" \
--type postgresql \
--connection-string "postgresql://readonly_user:secret@db.example.com:5432/sales"

For the full list of supported --type values, see Datasource Types.

Update a Datasource​

Rename an existing datasource:

lhc datasources update <id> --name "Sales DB (Production)"

Delete a Datasource​

lhc datasources delete <id>

Search Datasources​

lhc datasources search "sales"

Statistics​

lhc datasources statistics

Returns aggregate counts and metadata across all datasources.

Export a Datasource​

Export a datasource definition to a portable .lhc.json file:

# Print to stdout
lhc datasources export <id>

# Write to file
lhc datasources export <id> -f datasource.lhc.json

The export file contains the datasource configuration in a versioned schema format. It can be imported into a different Lakehousecat instance.

Import a Datasource​

lhc datasources import datasource.lhc.json

If a datasource with the same name already exists, the import is aborted and you are shown two options:

Error: HTTP 409: {"detail": "datasource ... already exists"}

A datasource with this name already exists.
Option A: delete it first: lhc datasources delete <id>
Option B: import with a different name: lhc datasources import <file> --name <new-name>

To import under a different name:

lhc datasources import datasource.lhc.json --name "Sales DB (Copy)"

Migration Example​

Export from one instance and import into another:

# Export from production profile
lhc --profile prod datasources export 779 -f sales.lhc.json

# Import into staging profile under a different name
lhc --profile staging datasources import sales.lhc.json --name "Sales DB (from prod)"