r-dbi / dbi3

DBI revisited
https://r-dbi.github.io/dbi3
37 stars 2 forks source link

Implement RStudio Connection Contract #11

Open krlmlr opened 6 years ago

krlmlr commented 6 years ago

Link: https://rstudio.github.io/rstudio-extensions/connections-contract.html

Should be possible by changing the implementation of the generic to

setGeneric("dbConnect",
  def = function(drv, ...) {
    con <- standardGeneric("dbConnect")
    register_con_with_rstudio(con)
    con
  },
  valueClass = "DBIConnection"
)

instead of the current implementation:

setGeneric("dbConnect",
  def = function(drv, ...) standardGeneric("dbConnect"),
  valueClass = "DBIConnection"
)

Similar for dbDisconnect(). I'm not sure about the connectionUpdated() entry point, because DBI currently doesn't provide notification.

Implementation sketch by @edgararuiz: https://gist.github.com/edgararuiz/0533b3daf70a41b70acd75c1e6a2b7a3.

Happy to review a PR. CC @nwstephens @jimhester.

krlmlr commented 6 years ago

This might need to wait until we have fleshed out r-dbi/DBI#24 in DBI.

edgararuiz-zz commented 6 years ago

A function that wraps connectionUpdated() can be added to DBI operations that make changes to the DB, such as dbWriteTable() and dbRemoveTable().

nwstephens commented 6 years ago

@krlmlr Just checking in on this issue. We consistently find ourselves wanting to demo RSQLite connections with Shiny apps. It would be great to have the connections contract working for Shiny developers who want to use database backends.

krlmlr commented 6 years ago

@jimhester: Do you have time to look into this?

krlmlr commented 6 years ago

Just agreed with @edgararuiz that he would take a look.

znmeb commented 5 years ago

Is this still blocked? I have a use case for it.

krlmlr commented 5 years ago

The yet-to-be-implemented conmgr will handle all new connections. In DBI, we'll call methods in conmgr if this package is installed. Clients will be able to register their own callbacks there.

dpprdan commented 4 years ago

@krlmlr I see that conmgr has been archived. Are there any new plans w.r.t. RStudion Connection Contracts in DBI?

Probably https://github.com/rstudio/connections

krlmlr commented 3 years ago

The connections package seems to wrap "DBIConnection" objects to achieve the desired result. I suspect we can simplify life for that package by providing callbacks.

krlmlr commented 2 years ago

https://github.com/rstudio/connections looks like the way to go. Perhaps we can provide connection events as part of a rewrite. Closing for now, bookmarking this issue.

edgararuiz commented 2 years ago

Right, connections is an external package the wraps DBI so it can open, update and close the Connections pane. The idea would be integrate the routines from connections into DBI. connections has a dependency on rscontract (https://github.com/rstudio/rscontract). The rscontract package is an interface tool that makes it easier to create and customize the Contract. I can see that eventually, DBI would have that same dependency.