Skip to content
Prev 66987 / 398513 Next

mysql retrive question

simone gabbriellini wrote:
Hi Simone,

If you use dbReadTable, as I mentioned in my previous email, you should 
be able to coerce myDataFrame to a numeric matrix.

A couple of extra observations: 
(1) If you really want to use fetch() to extract all the rows resulting
    from a SELECT statement in a single fetch, you may need to specify 
    n=-1, e.g.,

       > fetch(res, n = -1)

    otherwise you may only get the first 500 rows. (See ?fetch, ?MySQL, 
    and ?dbHasCompleted.) The reason there is this default is to prevent 
    crashing R with a very large and unexpected amount of data. By specifying 
    n=-1 you're effectively asserting that the output of SELECT can be 
    properly handled by R.

(2) Tables in a relational database are only superficially similar to
    data.frames (the SQL term "relation" for tables conveys semantics
    that do not exist in R), thus fetch() and dbReadTable() do not
    coerce their columns to factors.  Clearly, there is a need to allow
    users to specify their own converters, as other interfaces (e.g.,
    RSPython, RSPerl), and functions (e.g., read.table) actually provide.

Hope this helps,

--
David
Message-ID: <20050404120637.B21542@jessie.research.bell-labs.com>
In-Reply-To: <737ba45250b42aa1d804b75bd4871750@tin.it>; from ogabbrie@tin.it on Mon, Apr 04, 2005 at 04:32:36PM +0200