Description Usage Arguments Details Value See Also Examples
DAO is a list that provides basic backend CRUD functionality to the crudTableServer
. This
DAO uses DBI to store the data. The DBI table accessed with this DAO object must not contain the
'id'
attribute, as it is internally created from the DBI's 'rowid'
attribute.
1 |
con |
A DBI connection |
table |
A character string of the name of the table to be accessed |
typecast |
A named list of |
See dataFrameDao
for more details on Data Access Objects.
Since the DBI interface typically converts various complex R data types (such as Date
)
into atomic types such as number, character string and so on, sqlDao
may optionally
convert the data for you into a more convenient format – see the typecast
argument.
A DAO object, i.e. a list of functions for CRUD operations on the DBI table as neeeded by
the crudTableServer
module
dataFrameDao
, is.dao
, typecast
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | library(DBI)
library(RSQLite)
# Create an in-memory database
con <- dbConnect(RSQLite::SQLite(), ":memory:")
# Create an empty data table
data <- data.frame(date = character(0), value = numeric(0))
dbWriteTable(con, 'mytable', data)
# Create Data Access Object - the date attribute will be internally stored as character
# but transparently returned as 'Date' by the DAO
dao <- sqlDao(con,
table = 'mytable',
typecast = list(date = typecastDateToCharacter()))
# Insert data record
dao$insert(list(date = Sys.Date(), value = 100))
# Print data table
print(dao$getData())
# Disconnect from the database
dbDisconnect(con)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.