astra db data-api exec

astra db data-api exec [-qV] [--no-input] [--[no-]spinner] [--color[=WHEN]]
                       [--dump-logs[=FILE]] [-c[=COLLECTION[,
                       COLLECTION...]]]... [-t[=TABLE[,TABLE...]]]... [-e=CODE]
                       [-k=KEYSPACE] [-o=FORMAT] [-r=REGION] [-a=PACKAGES[,
                       PACKAGES...]]... [[[-cf=PATH] [-p=NAME]] |
                       [--token=TOKEN [--env=ENV]]] [--node | --python |
                       --ipython] [DB] [ARGS...]

Execute Data API code against a database

Options

DB

The name or ID of the Astra database to operate on

ARGS

Verbatim arguments to pass to the underlying node/python directly (anything after '--' is passed through)

-k, --keyspace

The keyspace to use

-a, --artifacts

Additional packages to include (e.g., pandas, lodash)

-r, --region

The region to use

-c, --collection

The collections to use

-t, --table

The tables to use

-e, --execute

Code to execute using the Data API

--node

Use astra-db-ts with Node.js (default)

--python

Use astrapy with Python

--ipython

Use astrapy with IPython

Common Options
-o, --output

One of: human, json, csv

-V, --verbose

Enable verbose logging output

-q, --quiet

Only output essential information

--spinner

Enable/disable loading spinners

--no-input

Don’t ask for user input (e.g. confirmation prompts)

--color

One of: auto, never, always

--dump-logs

Write all logs to an optionally specified file

Connection Options
-cf, --config-file

The .astrarc file to use for this command

-p, --profile

The .astrarc profile to use for this command. Can be set via ASTRA_PROFILE.

--token

The astra token to use for this command. Use the --token @file syntax to read the token from a file, to avoid potential leaks.

--env

Astra environment the token belongs to: prod (default), dev, or test. Leave unset unless you were issued a non-prod token.

Examples

# Insert a document using astra-db-ts (passing the -p flag to node)
$ astra db data-api exec my_db -c my_coll -e "my_coll.insertOne({ name: 'Joe' })" -- -p

# Find a row using python
$ astra db data-api exec my_db -l python -t my_table -e "print(my_table.find_one())"

# Execute a file
$ astra db data-api exec my_db -e @code.js

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM