Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

Commit

Permalink
fix issues #40 and #42
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes committed May 26, 2016
1 parent b2c7682 commit dbe2020
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export(monetdb.server.shutdown)
export(monetdb.server.getpid)

# dplyr.R
export(src_monetdb)
export(src_monetdb, src_monetdblite)
# rest of dplyr.R exported via hack in src_monetdb
8 changes: 3 additions & 5 deletions R/dbi.R
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,15 @@ setMethod("dbWriteTable", signature(conn="MonetDBConnection", name = "character"
levels(value[[c]]) <- enc2utf8(levels(value[[c]]))
}
if (inherits(conn, "MonetDBEmbeddedConnection")) {
if (csvdump) {
warning("Ignoring csvdump setting in embedded mode")
}
for (c in names(classes[classes=="Date"])) {
value[[c]] <- as.character(value[[c]])
}
for (c in names(classes[classes=="POSIXct"])) {
value[[c]] <- as.character(value[[c]])
}

insres <- monetdb_embedded_append(conn@connenv$conn, qname, value)
schema <- "sys"
if (temporary) schema <- "tmp"
insres <- monetdb_embedded_append(conn@connenv$conn, qname, value, schema)
if (!is.logical(insres)) {
stop("Failed to insert data: ", insres)
}
Expand Down
4 changes: 4 additions & 0 deletions R/dplyr.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
src_monetdblite <- function(dbdir = tempdir(), ...) {
src_monetdb(embedded = dbdir, ...)
}

src_monetdb <- function(dbname="demo", host = "localhost", port = 50000L, user = "monetdb",
password = "monetdb", con = FALSE, ...) {
if (!inherits(con, "MonetDBConnection") || !DBI::dbIsValid(con)) {
Expand Down
4 changes: 2 additions & 2 deletions man/dbApply.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
Apply a R function to an external MonetDB table.
}
\description{
\code{dbApply} is used to switch the data from the normal auto-commiting mode into transactional mode. Here, changes to the database will not be permanent until \code{dbCommit} is called. If the changes are not to be kept around, you can use \code{dbRollback} to undo all the changes since \code{dbTransaction} was called.
\code{dbApply} uses the R UDF facilities in standalone MonetDB to apply the passed function to a table.

}
\usage{
mdbapply(conn, table, fun, ...)
}
\arguments{
\item{conn}{An external MonetDB.R database connection. Created using \code{\link[DBI]{dbConnect}}
with the \code{\link[MonetDB.R]{MonetDB.R}} external database driver.}
with the \code{\link[MonetDBLite]{MonetDB.R}} external database driver.}
\item{table}{An external MonetDB database table. Can also be a view or temporary table.}
\item{fun}{A R function to be run on the external database table. The function gets passed a single \code{data.frame} argument which represents the database table. The function needs to return a single vector (for now).}
\item{...}{Other parameters to be passed to the function}
Expand Down
5 changes: 5 additions & 0 deletions man/src_monetdb.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
\name{src_monetdb}
\alias{src_monetdb}
\alias{src_monetdblite}
\alias{tbl.src_monetdb}
\alias{src_desc.src_monetdb}
\alias{src_translate_env.src_monetdb}
Expand All @@ -20,6 +21,8 @@
src_monetdb(dbname, host = "localhost", port = 50000L, user = "monetdb",
password = "monetdb", con=FALSE, ...)

src_monetdb(dbdir = tempdir(), ...)

\method{tbl}{src_monetdb}(src, from, ...)
}
\arguments{
Expand All @@ -36,6 +39,8 @@ database connector, \code{dbConnect}.}

\item{src}{a MonetDB src created with \code{src_monetdb}.}

\item{dbdir}{a directory to start MonetDBLite in}

\item{from}{Either a string giving the name of table in database, or SQL described a derived table or compound join.}
}
\description{
Expand Down

0 comments on commit dbe2020

Please sign in to comment.