, database, job_name=None, client=None, credential_id=None, polling_interval=None, hidden=True, csv_settings=None)[source]

Store results of a query to a Civis file


The SQL select string to be executed.

databasestr or int

Execute the query against this database. Can be the database name or ID.

job_namestr, optional

A name to give the job. If omitted, a random job name 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 database credential ID. If None, the default credential will be used.

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.

csv_settingsdict, optional

A dictionary of csv_settings to pass to civis.APIClient.scripts.post_sql().


A future which returns the response from civis.APIClient.scripts.get_sql_runs() after the sql query has completed and the result has been stored as a Civis file.

See also

Read directly into memory without SQL.

Read results of a SQL query into memory.

Write directly to a CSV file.

Upload a Civis file to a Civis table


>>> sql = "SELECT * FROM schema.table"
>>> fut = export_to_civis_file(sql, "my_database")
>>> file_id = fut.result()['output'][0]["file_id"]