Hi all, I just noticed (the hard way of course) that when a query returns 0 rows, the columns in the resulting data.frame get dropped as well. See the following example code (where conn is an active connection to an SQLite db): > dbGetQuery(conn, "select 1 as hey, 2 as ho where 1") hey ho 1 1 2 > dbGetQuery(conn, "select 1 as hey, 2 as ho where 0") data frame with 0 columns and 0 rows I believe that the second query should return a 0x2 data.frame instead, that is, the same value as: > dbGetQuery(conn, "select 1 as hey, 2 as ho where 1")[FALSE,] [1] hey ho <0 rows> (or 0-length row.names) Any thoughts? Is this a bug, and are the developers of RSQLite reading this? Best regards, Magnus
Hi Magnus, Magnus Torfason <zulutime.net <at> gmail.com> writes:> I just noticed (the hard way of course) that when a query returns 0 > rows, the columns in the resulting data.frame get dropped as well. See > the following example code (where conn is an active connection to an > SQLite db): > > > dbGetQuery(conn, "select 1 as hey, 2 as ho where 1") > hey ho > 1 1 2 > > dbGetQuery(conn, "select 1 as hey, 2 as ho where 0") > data frame with 0 columns and 0 rows > > I believe that the second query should return a 0x2 data.frame instead, > that is, the same value as:I agree that keeping the column dimension is sensible. I will see about fixing that for the next release.> Any thoughts? Is this a bug, and are the developers of RSQLite > reading this?A much better forum for RSQLite issues is the r-sig-db list. + seth
Apparently Analagous Threads
- Creating a list of empty lists
- Searching for a string in RSQLite
- Data type problem when extract data from SQLite to R by using RSQLite
- RSQLite does not read very large values correctly
- Basic question: Reading in multiple choice question responses to a single column in data frame