Skip to content
Prev 1344 / 1559 Next

SQL generics

Right.  Dispatching on conn would be a bit confusing for users, but I
think these would mostly be used by package authors.
No, I don't think so - the layer of commands built on top of the sql*
functions would be more like dbWriteTable - i.e. they'd map to
operations that make more sense from the R side of things, rather than
being a straightforward translation to things that make sense to
databases.
I'm not a big fan of functions that return different types based on
their input arguments because they're harder to program against.
However, you could imagine these functions returning some sort of
reference class from which you could either extract the sql, or you
could run the query once. But that seems a bit too complicated for
DBI.
Yes, I've spent quite a lot of time on this for the dplyr package,
which provides a syntax that allows you to work with data frames, data
tables and databases (sqlite, mysql, postgresql and google big query)
without having to worry too much about the how the data is stored. But
the only way to do this is to carefully constrain the problem domain,
and I think there's too much variation in SQL grammars for SQL to
serve as the abstraction layer (not without a huge amount of work
anyway).

Some of the methods might only actually be useful transiently while
you're developing a new DBI package (i.e. once you've implemented
sqlCreateTable and sqlInsertInto you get an inefficient dbWriteTable
for free), or for testing. But I don't think that's necessarily a
problem.

Hadley