dbConnectionInfo {Rdbi}R Documentation

Returns a list of connection status attributes


dbConnectionInfo is a generic function that, when called on a valid connection object, returns a list containing connection status information. It is called by print.Rdbi.conn.




conn A database connection object.


Any useful information such as the database host and connection status should be returned.


An arbitrary list of connection attributes.


I should probably define a dbConnectionOK method that is generic and return TRUE when the connection is valid. However, you don't need to constantly check for a valid connection object. Keep the code path short! For example, in Rdbi.PgSQL, there is a C function that submits a query request to the database backend. This is the only time that the connection object is actually derefenced to its connection pointer. This C function checks for a valid connection and returns and error if needed. Therefore there is no reason to check whether the connection is valid before passing it to a query function; the C code will do the check. In this way the interface is simplified and the connection checking is localized to a single call instead of scattered all over the code. As Bertrand Meyer put it: "Defensive coding is offensive!".


Timothy H. Keitt



See Also

dbConnect, dbDisconnect, methods, class

[Package Rdbi version 1.0.4 Index]