Closing an unused RODBC handle

I get a warning message:

`historicalHourly <- importHistoricalHourly(startDatePast,endDatePast,Markets,location) [1] "Importing Hourly Data" [1] "Flag - Moving from importHistoricalHourly to CleaningUpHourly" [1] "Flag - Moving to importHistoricalDaily from CleaningUpHourly"Warning messages: 1: closing unused RODBC handle 41 2: closing unused RODBC handle 40 3: closing unused RODBC handle 36` 

In the function, everything is checked for return values, it displays statements. I have an idea that this is definitely a warning because of this function:

hHourly.df <- retrievelim(PowerCodeID,columns,startDatePast,endDatePast,unitstr="Hours")

which accesses a separate database in another program. This function returns a data frame from DateTime values ​​by the clock with different numerical values ​​in the next column.

If anyone can give me an idea of ​​why it is closing the database and what is happening, I would really appreciate it.

+4
source share
1 answer

This is because this function contains odbcConnect(...) without odbcClose(...) , as joran suggests. Since the odbcConnect object is created inside the function, it expects to be deleted the next time it collects garbage ( ?gc ). Sometimes this happens when you call a function, sometimes it happens later.

When the odbcConnect object is deleted using gc() , it closes the database connection and displays a message. Do not worry about anything.

+10
source

Source: https://habr.com/ru/post/1487378/


All Articles