[R] sqldf and number of records affected
Ravi Jeyaraman
r@v|76 @end|ng |rom gm@||@com
Thu Jun 11 16:06:35 CEST 2020
Thanks for the response Gabor. Looks like the below example will work when using SQLite, but in my case I'm just creating a dataframe in R and trying to update it using sqldf as below and it doesn't seem to work ...
con <- data.frame(V1 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
sqldf()
sqldf(c("pragma count_changes = 1", "update con set V1 = 0 where V1 > 5 "))
ans <- sqldf("select * from main.con")
sqldf()
-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck using gmail.com]
Sent: Thursday, June 11, 2020 9:12 AM
To: Ravi Jeyaraman <ravi76 using gmail.com>
Cc: r-help using r-project.org
Subject: Re: [R] sqldf and number of records affected
Here is an example. Ignore the warning or use the workaround discussed here
https://github.com/ggrothendieck/sqldf/issues/40
to avoid the warning.
library(sqldf)
sqldf() # use same connection until next sqldf()
sqldf(c("pragma count_changes = 1", "update BOD set demand = 99 where Time > 4"))
sqldf("select * from main.BOD")
sqldf()
On Thu, Jun 11, 2020 at 9:01 AM Ravi Jeyaraman <ravi76 using gmail.com> wrote:
>
> Hello all, When I execute a SQL using SQLDF, how do I get the number
> of records affected? I mean, if I run an UPDATE on a data frame, it
> doesn't tell me if and how many records got updated. I've read
> through the documentation and there don't seem to be a way to get this
> info unless it's done on a database. Any ideas?
>
> Thanks
> Ravi
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
--
This email has been checked for viruses by AVG.
https://www.avg.com
More information about the R-help
mailing list