DSD_ReadDB

0th

Percentile

Read a Data Stream from an open DB Query

A DSD class that reads a data stream from an open DB result set from a relational database with using R's data base interface (DBI).

Usage
DSD_ReadDB(result, k=NA, class=NULL, description=NULL)
Arguments
result
An open DBI result set.
k
Number of true clusters, if known.
class
column index for the class/cluster assignment.
description
a character string describing the data.
Details

This class provides a streaming interface for result sets from a data base with via DBI. You need to connect to the data base and submit a SQL query using dbGetQuery() to obtain a result set. Make sure that your query only includes the columns that should be included in the stream. Do not forget to close the result set and the data base connection.

Value

An object of class DSD_ReadDB (subclass of DSD_R, DSD).

See Also

DSD, dbGetQuery

Aliases
  • DSD_ReadDB
Examples
### create a data base with a table with 3 Gaussians
library("RSQLite")
con <- dbConnect(RSQLite::SQLite(), ":memory:")

points <- get_points(DSD_Gaussians(k=3, d=2), 600, class = TRUE)
head(points)

dbWriteTable(con, "gaussians", points)
  
### prepare a query result set  
res <- dbSendQuery(con, "SELECT X1, X2, class FROM gaussians")
res
  
### create a stream interface to the result set  
stream <- DSD_ReadDB(res, k=3, class = 3)

### get points
get_points(stream, 5, class = TRUE)  
plot(stream)
  
### clean up  
dbClearResult(res)
dbDisconnect(con)
Documentation reproduced from package stream, version 1.2-3, License: GPL-3

Community examples

Looks like there are no examples yet.