Warning message: Closing unused connection x

2,515 views
Skip to first unread message

yvette....@gmail.com

unread,
Dec 7, 2014, 2:48:44 PM12/7/14
to sq...@googlegroups.com
I am trying to find why when running this piece of code using sqldf commands it produces a warning message about unused connection:

code:

library(sqldf)

## Create a small DF
subject <- 1:10
gender <- sample(c("F","M"), 10, replace=TRUE)

DF1 <- data.frame(subject, gender)

# Write myDF to a txt file
write.csv(DF1, "myTestFile.txt", row.names=FALSE)

DF2 <- read.csv.sql("myTestFile.txt", 'select * from file')

## write some information on that DF
str(DF2)
summary(DF2)


What it gives:

library(sqldf)
>
> ## Create a small DF
> subject <- 1:10
> gender <- sample(c("F","M"), 10, replace=TRUE)
>
> DF1 <- data.frame(subject, gender)
>
> # Write myDF to a txt file
> write.csv(DF1, "myTestFile.txt", row.names=FALSE)
>
> DF2 <- read.csv.sql("myTestFile.txt", 'select * from file')
Warning message:
closing unused connection 3 (myTestFile.txt)
>
> ## write some information on that DF
> str(DF2)
'data.frame': 10 obs. of 2 variables:
$ subject: int 1 2 3 4 5 6 7 8 9 10
$ gender : chr "\"M\"" "\"M\"" "\"M\"" "\"F\"" ...
> summary(DF2)
subject gender
Min. : 1.00 Length:10
1st Qu.: 3.25 Class :character
Median : 5.50 Mode :character
Mean : 5.50
3rd Qu.: 7.75
Max. :10.00
Warning message:
closing unused connection 4 (myTestFile.txt)

Any idea?
Arguments forgot?

Gabor Grothendieck

unread,
Dec 7, 2014, 5:49:21 PM12/7/14
to sq...@googlegroups.com
Its just a warning, not an error.  Issue the command

    closeAllConnections()

after the read.csq.sql to avoid it.
Reply all
Reply to author
Forward
0 new messages