tb datasource

Manages data sources. Global options apply to this command. See Global options.

The following subcommands are available:

SubcommandDescription
create [OPTIONS]Creates a new .datasource file from a URL, local file or a connector.
analyze URL_OR_FILEAnalyzes a URL or a file before creating a new data source.
append DATASOURCE_NAME [OPTIONS]Appends data to an existing data source from URL, local file or via Events API. For example, tb datasource append my_datasource --url https://my_url.com.
dataPrints data from a data source.
delete [OPTIONS] DATASOURCE_NAMEDeletes specific rows from a data source given a SQL condition.
export [OPTIONS] DATASOURCE_NAMEExports data from a data source to a local file in CSV or NDJSON format.
ls [OPTIONS]Lists data sources.
replace DATASOURCE_NAME URLReplaces the data in a data source from a URL, local file or a connector.
sync [OPTIONS] DATASOURCE_NAMESyncs from connector defined in .datasource file.
truncate [OPTIONS] DATASOURCE_NAMETruncates a data source.

tb datasource create

Creates a new .datasource file. Opens a wizard if no arguments are provided.

OptionDescription
--name TEXTName of the data source
--blankCreate a blank data source
--file TEXTCreate a data source from a local file
--url TEXTCreate a data source from a remote URL
--connection TEXTCreate a data source from a connection
--prompt TEXTCreate a data source from a prompt
--s3Create a data source from a S3 connection
--gcsCreate a data source from a GCS connection
--kafkaCreate a data source from a Kafka connection

tb datasource analyze

Analyzes a URL or a local file before creating a new data source. It prints the column names, data type and nullable status of each column, and the SQL schema of the data file.

For example, tb datasource analyze telemetry.ndjson will return the following:

nametypenullable
altitudeFloat64false
latitudeFloat32false
longitudeFloat32false
nameStringfalse
timestampDateTime64false
altitude Float64 `json:$.altitude`, latitude Float32 `json:$.latitude`, longitude Float32 `json:$.longitude`, name String `json:$.name`, timestamp DateTime64 `json:$.timestamp`

tb datasource append

Appends data to an existing data source from URL, local file or a connector.

OptionDescription
--url TEXTURL to append data from
--file TEXTLocal file to append data from
--events TEXTEvents to append data from TEXT in NDJSON format
-h, --helpExplains append command and options

tb datasource data

Prints data from a data source.

OptionDescription
--limit INTEGERLimits the number of rows to return

tb datasource delete

Deletes rows from a data source with SQL condition. For example: tb datasource delete [datasource_name] --sql-condition "country='ES'"

OptionDescription
--yesDoes not ask for confirmation
--waitWaits for delete job to finish
--dry-runRuns the command without deleting anything

tb datasource export

Exports data from a data source to a local file in CSV or NDJSON format.

For example:

  • Export all rows as CSV: tb datasource export my_datasource
  • Export 1000 rows as NDJSON: tb datasource export my_datasource --format ndjson --rows 1000
  • Export to specific file: tb datasource export my_datasource --target ./data/export.csv
OptionDescription
--format [csv|ndjson]Output format (CSV or NDJSON)
--rows INTEGERNumber of rows to export (default: 100)
--where TEXTCondition to filter data
--target TEXTTarget file path. Default is datasource_name.{format}
-h, --helpExplains export commmand and options

tb datasource ls

Lists data sources.

OptionDescription
--match TEXTRetrieves any resource matching the pattern
--format [json]Returns the results in the specified format

tb datasource sync

Sync data source to S3 bucket.

OptionDescription
--yesDoes not ask for confirmation

tb datasource truncate

Truncates a data source. For example, tb datasource truncate my_datasource.

OptionDescription
--yesDoes not ask for confirmation
--cascadeTruncates the dependent data source attached in cascade to the given data source
Updated