civis.io.query_civis

civis.io.query_civis(sql, 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().

Parameters:
sql : str

The SQL statement to execute.

database : str or int

The name or ID of the database.

api_key : DEPRECATED str, optional

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

client : civis.APIClient, optional

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

credential_id : str or int, optional

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

preview_rows : int, optional

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

polling_interval : int or float, optional

Number of seconds to wait between checks for query completion.

hidden : bool, optional

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

Returns:
results : CivisFuture

A CivisFuture object.

Examples

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