civis.io.civis_to_csv

civis.io.civis_to_csv(filename, sql, database, job_name=None, api_key=None, client=None, credential_id=None, archive=False, hidden=True, polling_interval=None)

Export data from Civis to a local CSV file.

Parameters:

filename : str

Download exported data into this file.

sql : str, optional

The SQL select string to be executed.

database : str or int

Export data from this database. Can be the database name or ID.

job_name : str, optional

A name to give the job. If omitted, a random job name will be used.

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.

polling_interval : int or float, optional

Number of seconds to wait between checks for query completion.

archive : bool, optional (deprecated)

If True, archive the import job as soon as it completes.

hidden : bool, optional

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

Returns:

results : CivisFuture

A CivisFuture object.

See also

civis.io.read_civis
Read table contents into memory.
civis.io.read_civis_sql
Read results of a SQL query into memory.

Examples

>>> sql = "SELECT * FROM schema.table"
>>> fut = civis_to_csv("file.csv", sql, "my_database")
>>> fut.result()  # Wait for job to complete