download_civis
downloads a file based on the type of its first
argument, which can be a string "schema.table"
,
a SQL query sql(...)
, or a numeric file ID.
A table or a query from Redshift will be downloaded onto disk as a CSV. A file from Platform files endpoint will be downloaded as is.
A default database can be set using options(civis.default_db = "my_database")
.
If there is only one database available,
this database will automatically be used as the default.
download_civis(x, ...) # S3 method for character download_civis( x, database = NULL, file, overwrite = FALSE, progress = FALSE, split = FALSE, job_name = NULL, hidden = TRUE, verbose = FALSE, ... ) # S3 method for sql download_civis( x, database = NULL, file, overwrite = FALSE, progress = FALSE, split = FALSE, job_name = NULL, hidden = TRUE, verbose = FALSE, ... ) # S3 method for numeric download_civis(x, file, overwrite = FALSE, progress = FALSE, ...)
x |
|
---|---|
... | Currently ignored. |
database | string, The database. If |
file | string, The file to write to. |
overwrite | logical, Whether to overwrite the existing |
progress | logical, Whether to display a progress bar. |
split | logical, Whether to download a big table by splitting it into multiple
CSV parts first. See |
job_name | string, Name of the job (default: |
hidden | logical, Whether the job is hidden on Platform. |
verbose | logical, Whether to print detailed updates of job status. |
The file where the downloaded files or tables are written to. It is returned invisibly.
character
: Download a table from Redshift to disk as CSV.
sql
: Download the result of a SQL query from Redshift to disk as CSV.
numeric
: Download a file from Platform files endpoint to disk.
Other io:
query_civis_file()
,
query_civis()
,
read_civis()
,
write_civis_file()
,
write_civis()
if (FALSE) { # Download all columns in a single table into a CSV download_civis("schema.table", database = "my_database", file = "~/Downloads/my_table.csv") # Download data from a SQL select statement into a CSV query <- sql("SELECT * FROM table JOIN other_table USING id WHERE var1 < 23") download_civis(query, database = "my_database", file = "~/Downloads/my_table.csv") # Set a default database options(civis.default_db = "my_database") # Download any file from the files endpoint. file_id <- write_civis_file(df) download_civis(file_id, file = "df.rds", progress = TRUE) df2 <- readRDS("df.rds") identical(df, df2) }