DBI connection lost

I am developing a package that provides easier access to pull information from a database

I create a database connect object (oracle) using

con <- DBI::dbConnect(odbc::odbc(), dsn=server,uid=uid,pwd=pwd, timeout = 10)

con is then passed to various functions in the package to pull certain kinds of data.

Every time i build my package the con object is no longer valid. It is still in memory and on inspection appears ok however it is rejected by the database. So i have to create a new connection object. I don't understand why building a package would do this.

Is this a DBI error, or user error, or something else?

Any ideas?

Hi, are you using "Install and Restart" to rebuild the package. If so, I would say that you're having that issue because "on exit" DBI closes the DB connection, so even though your con object is reloaded to your Environment, it is not a valid connection for Oracle any longer because DBI told it to close it during the "Restart" part of the process. If that's the case, maybe using "Load All" may be less impactful in your prototyping cycle.

If @edgararuiz 's answer does not solve your issue, then I am afraid that you'd need to show us a complete example. E.g. if your package is open source, then can you provide a link to it?

This topic was automatically closed 7 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.