System details
RStudio Edition : Desktop
RStudio Version : 1.2.1511
OS Version : Windows 7
R Version : 3.6.0
I am connecting my organisation's database using Sybase IQ as well as RStudio via ODBC connection.
I can export SQL results to a csv
file in Interactive SQL app with the following codes
select top 10* into #test from DATA;
select * from #test;
output to "E:\\test.csv";
However, neither output to
nor into outfile
(in some other suggestions) works via RStudio's SQL engine.
Is there anyway I can achieve this?
LJJ
May 3, 2019, 1:02pm
2
Hi,
Using the DBI package,
Allocate the output of the SQL to a variable, then save as a data frame before export to csv, without a computer (only mobile) it's something like:
Library(DBI)
con = dbConnect(#connection string)
X<- dbSendQuery(con, "select * from table")
X<-as.data.frame(X)
Then write X to csv using write_csv(x,"filepath.csv")
Just to clarify, are you talking about doing this with sql code from a sql script file or sql chunk within RStudio, or you are talking about how to do this with R?
1 Like
This is about how to do this with SQL code from a SQL script within RStudio.
Thanks for that. I am more interested in doing this with now RStudio supported SQL script since Version 1.2, and why it doesn't work with SQL code.
1 Like
system
Closed
May 25, 2019, 5:15am
6
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.