Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RStudio Connection Contract #11

Open
krlmlr opened this issue Dec 4, 2017 · 11 comments
Open

Implement RStudio Connection Contract #11

krlmlr opened this issue Dec 4, 2017 · 11 comments

Comments

@krlmlr
Copy link
Member

krlmlr commented Dec 4, 2017

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
Copy link
Member Author

krlmlr commented Dec 4, 2017

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

@edgararuiz-zz
Copy link

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

@nwstephens
Copy link

@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
Copy link
Member Author

krlmlr commented Jan 25, 2018

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

@krlmlr
Copy link
Member Author

krlmlr commented Feb 6, 2018

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

  • Implement a function dbiRegisterCallbacks() and dbiUnregisterCallbacks()
    • dbiRegisterCallbacks <- function(name, ..., connect, disconnect, write_table, remove_table, clear_result)
    • dbiUnregisterCallbacks <- function(name)
  • Add calls to the callbacks in the relevant generic

@znmeb
Copy link

znmeb commented Dec 30, 2018

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

@krlmlr
Copy link
Member Author

krlmlr commented Feb 3, 2019

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
Copy link

dpprdan commented Aug 17, 2020

@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
Copy link
Member Author

krlmlr commented Sep 28, 2020

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
Copy link
Member Author

krlmlr commented Oct 17, 2021

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.

@krlmlr krlmlr closed this as completed Oct 17, 2021
@krlmlr krlmlr transferred this issue from r-dbi/DBI Oct 31, 2021
@krlmlr krlmlr reopened this Oct 31, 2021
@edgararuiz
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants