civis.io.civis_to_csv¶
-
civis.io.
civis_to_csv
(filename, sql, database, job_name=None, api_key=None, credential_id=None, archive=False, hidden=True, polling_interval=15)¶ 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 : str, optional
Your Civis API key. If not given, the
CIVIS_API_KEY
environment variable will be used.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 :
PollableResult
A PollableResult 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" >>> poll = civis_to_csv("file.csv", sql, "my_database") >>> poll.result() # Wait for job to complete