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.
For types that authenticate with a service-account JSON file instead of a connection string
(google_analytics, google_sheets, bigquery), use --credentials-file instead of
--connection-string:
lhc datasources create \
--name "GA4 Prod" \
--type google_analytics \
--credentials-file ./service-account.json
The CLI reads the file locally and uploads its contents — the path itself is never stored.
--connection-string, --credentials-file and --settings-file may be combined for types that
need more than one; see lhc datasources create --help for the full flag set.
Update a Datasource
Rename an existing datasource:
lhc datasources update <id> --name "Sales DB (Production)"
Rotate credentials on an existing datasource of one of the three JSON-credential types:
lhc datasources update <id> --credentials-file ./service-account.json
Delete a Datasource
lhc datasources delete <id>
Search Datasources
lhc datasources search "sales"
lhc datasources search --tag RED
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)"