SQLite: Difference between revisions

Jump to navigation Jump to search
122 bytes removed ,  4 years ago
Line 40: Line 40:
# after which you can use code like the following to interact with the SQLite database
# after which you can use code like the following to interact with the SQLite database
library(DBI)
library(DBI)
age <- 34
query <- ""


# Connect to the database...
# Connect to the database...
Line 45: Line 48:


# A parameterized query
# A parameterized query
rs <- dbSendQuery(dbase,"SELECT * FROM tname",params = list(tname = "employees"))
paste(c("INSERT INTO employee(name,age) VALUES(\"John Smith\",",toString(age),");",query),collapse='')
while (!dbHasCompleted(rs)) {
ierr <- dbExecute(dbase,query)
  # Grab a maximum of ten rows at a time...
  df <- dbFetch(rs,n = 10)
  # Print the number of rows we actually got from dbFetch
  print(nrow(df))
}
dbClearResult(rs)


# Close the database connection
# Close the database connection
Bureaucrats, cc_docs_admin, cc_staff
2,318

edits

Navigation menu