r-dbi / dbi3

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

Feature Request: Virtual connection #50

Open mgirlich opened 2 years ago

mgirlich commented 2 years ago

For testing purposes it would be great to have something like a "virtual" connection. That is, a connection that can be created without actually connecting to a database. This connection could then be used in functions like DBI::dbQuoteLiteral() that don't need a live connection. The dbplyr package has something like this with the simulate_*() functions. This can be useful for testing when one cannot connect locally to a specific database. I also think/hope one could then get rid of some code duplication between dbplyr and the DBI packages, for example quoting literals is also defined in dbplyr.

krlmlr commented 2 years ago

Thanks for raising this, good idea. For DBI you can create a class that inherits from the correct connection class, if necessary implement a dbSendQuery() method that fails. Providing the mock class would be a job for the backend packages.

krlmlr commented 2 years ago

Does {dittodb} solve this?