, database, api_key=None, client=None, credential_id=None, preview_rows=10, polling_interval=None, hidden=True)[source]

Execute a SQL statement as a Civis query.

Run a query that may return no results or where only a small preview is required. To execute a query that returns a large number of rows, see read_civis_sql().


The SQL statement to execute.

databasestr or int

The name or ID of the database.

api_keyDEPRECATED str, optional

Your Civis API key. If not given, the CIVIS_API_KEY environment variable will be used.

clientcivis.APIClient, optional

If not provided, an civis.APIClient object will be created from the CIVIS_API_KEY.

credential_idstr or int, optional

The ID of the database credential. If None, the default credential will be used.

preview_rowsint, optional

The maximum number of rows to return. No more than 100 rows can be returned at once.

polling_intervalint or float, optional

Number of seconds to wait between checks for query completion.

hiddenbool, optional

If True (the default), this job will not appear in the Civis UI.


A CivisFuture object.


>>> run = query_civis(sql="DELETE schema.table", database='database')
>>> run.result()  # Wait for query to complete