[R-sig-DB] dbListConnections() not working in RSQLite?

Jonathan Greenberg greenberg @end|ng |rom ucd@v|@@edu
Tue Jul 6 00:12:56 CEST 2010


This is a fork off my previous discussion -- trying to troubleshoot
locking and connections has led me to try using dbListConnections().
Using Seth's example for solving the problem of concurrent read/writes
to a database, I tossed in a "print(dbListConnections(m))" into the
main while() loop:

***

library("RSQLite")
mysqldb='test.sqlite'
unlink(mysqldb)
fetch_n=3

# Create a data table.
somedata=data.frame(data1=seq(1:10),data2=seq(1:10)*3)

# Make a table in our database with it.
m <- dbDriver("SQLite")
con=dbConnect(m, dbname=mysqldb)
dbWriteTable(con,"TABLEA",somedata,overwrite=TRUE)
dbGetQuery(con, "CREATE table t2 (data1 INTEGER, data2 FLOAT)")
dbDisconnect(con)

# Now we want to read from TABLEA in "chunks" and write to TABLEB.
read_con=dbConnect(m, dbname=mysqldb)
write_con=dbConnect(m, dbname=mysqldb)

read_query=dbSendQuery(read_con,"SELECT * FROM TABLEA")
dbBeginTransaction(write_con)
while (!dbHasCompleted(read_query))
{
	read_chunk=fetch(read_query,fetch_n)
	new_data=data.frame(data3=read_chunk$data1*4,data4=read_chunk$data2*4)
	dbGetPreparedQuery(write_con, "INSERT into t2 values (?, ?)", new_data)
	print(dbListConnections(m))
}
dbClearResult(read_query)
dbCommit(write_con)

dbDisconnect(read_con)
dbDisconnect(write_con)

***

The response from this statement is:
list()
list()
list()
list()

Am I missing something?  I'm noticing this behavior on the MacOS X
install of RSQLite as well as a Debian amd x64 install.

--j




More information about the R-sig-DB mailing list