[R] RODBC connections w/o specific database

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Apr 16 17:34:28 CEST 2007

On Mon, 16 Apr 2007, Pete Cap wrote:

> Folks,
> I'm writing a gui wrapper around RODBC (having abandoned RMySQL) and 
> some custom analysis scripts.  I'm hoping that I could get some advice.
> All of my users will have access to a database server.  I am going to 
> limit their access to certain databases--a sizeable warehouse in a SAN, 
> and then smaller storage that they can use for temp files and personal 
> tables.  I want to present these to the user using a tktree widget, 
> rather like you might see in Enterprise Guide, with the top level of 
> each tree being a specific database and branches being tables.
> Can I get some advice on a good way to accomplish this?
> Right now I can create and connect to a DSN that does not specify a 
> database.  I suppose that upon connection I could use sqlQuery to get 
> the names of databases and their tables, then use the result to populate 
> the tree.  However, once a table has been selected, would I need to 
> create a new connection (since the existing connection does not specify 
> a database) or could I use the existing one for everything and just 
> specify database and table in my queries?

You could, but then your tables would all need to accessed via db.table 
names (assuming your DBMS supports that).  Opening a new connection is 
cheap (and will be cheaper in RODBC 1.2.z) so I would just do that.

> Also, any additional advice on would be appreciated if anyone has any.
> Thanks,
> Pete
> ---------------------------------
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list