Quantcast

sqldf hanging on macintosh - works on windows

classic Classic list List threaded Threaded
9 messages Options
GL
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

sqldf hanging on macintosh - works on windows

GL
Have a long script that runs fine on windows (32 bit). When I try to run in on two different macs (64 bit), however, it hangs with identical behavior.

I start with:
library(sqldf)

This results in messages:
Loading required package: DBI
Loading required package: RSQLite
Loading required package: RSQLite.extfuns
Loading required package: gsubfn
Loading required package: proto
Loading required package: chron

I then read some data, etc.

I execute the following:

#merge raw data and all possible combinations
  df.final <- sqldf('select Date, Hour, x as RoomsInUse from "df.possible.combos"
    left join "df.aggregate" using (Hour, Date)')

I receive the messages:
Loading required package: tcltk
Loading Tcl/Tk interface ...
+

Then I get into some kind of loop. Message at bottom ribbon says:

executing: try(gsub('\\s+','',paste(capture.output(print(arg(summary))),collapse=")),silent=TRUE)

On the pc implementation it runs flawlessly, and quickly.

Truly appreciate any ideas.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sqldf hanging on macintosh - works on windows

Gabor Grothendieck
On Mon, Nov 1, 2010 at 9:59 AM, GL <[hidden email]> wrote:

>
> Have a long script that runs fine on windows (32 bit). When I try to run in
> on two different macs (64 bit), however, it hangs with identical behavior.
>
> I start with:
> library(sqldf)
>
> This results in messages:
> Loading required package: DBI
> Loading required package: RSQLite
> Loading required package: RSQLite.extfuns
> Loading required package: gsubfn
> Loading required package: proto
> Loading required package: chron
>
> I then read some data, etc.
>
> I execute the following:
>
> #merge raw data and all possible combinations
>  df.final <- sqldf('select Date, Hour, x as RoomsInUse from
> "df.possible.combos"
>    left join "df.aggregate" using (Hour, Date)')
>
> I receive the messages:
> Loading required package: tcltk
> Loading Tcl/Tk interface ...
> +
>
> Then I get into some kind of loop. Message at bottom ribbon says:
>
> executing:
> try(gsub('\\s+','',paste(capture.output(print(arg(summary))),collapse=")),silent=TRUE)
>

That is not a line that appears in the sqldf source code.  Try these
suggestions anyways:

http://permalink.gmane.org/gmane.comp.lang.r.general/209443


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
GL
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sqldf hanging on macintosh - works on windows

GL
added library(RH2)

Still get message:

Loading required package: tcltk
Loading Tcl/Tk interface....
+

directly after sqldf statement

>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from "df.possible.combos"
+     left join "df.aggregate" using (Hour, Date)')

There is no progress spinner. If I hit <enter> I get a ">"

At that point I start to enter any command (just summary, for instance), I get the progress spinner, the "try(gsub('\\s+','',paste(capture.output(print(arg(summary))),collapse=")),silent=TRUE) " message in the bottom ribbon, and the system apparently hangs.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sqldf hanging on macintosh - works on windows

Gabor Grothendieck
On Mon, Nov 1, 2010 at 10:32 AM, GL <[hidden email]> wrote:

>
> added library(RH2)
>
> Still get message:
>
> Loading required package: tcltk
> Loading Tcl/Tk interface....
> +
>
> directly after sqldf statement
>
>>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
>> "df.possible.combos"
> +     left join "df.aggregate" using (Hour, Date)')
>
> There is no progress spinner. If I hit <enter> I get a ">"
>
> At that point I start to enter any command (just summary, for instance), I
> get the progress spinner, the
> "try(gsub('\\s+','',paste(capture.output(print(arg(summary))),collapse=")),silent=TRUE)
> " message in the bottom ribbon, and the system apparently hangs.

I don't have a Mac but if you wish to pursue it try this:

library(sqldf)
debug(sqldf)
sqldf(...whatever...)
# now step through it by repeatedly pressing Enter and send me the
console output of the session

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
GL
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sqldf hanging on macintosh - works on windows

GL

>
> library(sqldf)
Loading required package: DBI
Loading required package: RSQLite
Loading required package: RSQLite.extfuns
Loading required package: gsubfn
Loading required package: proto
Loading required package: chron
> debug(sqldf)  
>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from "df.possible.combos"
+     left join "df.aggregate" using (Hour, Date)')
debugging in: sqldf("select Date, Hour, x as RoomsInUse from \"df.possible.combos\"\n    left join \"df.aggregate\" using (Hour, Date)")
debug: {
    as.POSIXct.character <- function(x) structure(as.numeric(x),
        class = c("POSIXt", "POSIXct"))
    as.Date.character <- function(x) structure(as.numeric(x),
        class = "Date")
    as.Date.numeric <- function(x, origin = "1970-01-01", ...) base::as.Date.numeric(x,
        origin = origin, ...)
    as.dates.character <- function(x) structure(as.numeric(x),
        class = c("dates", "times"))
    as.times.character <- function(x) structure(as.numeric(x),
        class = "times")
    overwrite <- FALSE
    request.open <- missing(x) && is.null(connection)
    request.close <- missing(x) && !is.null(connection)
    request.con <- !missing(x) && !is.null(connection)
    request.nocon <- !missing(x) && is.null(connection)
    dfnames <- fileobjs <- character(0)
    if (request.close || request.nocon) {
        on.exit({
            dbPreExists <- attr(connection, "dbPreExists")
            dbname <- attr(connection, "dbname")
            if (!missing(dbname) && !is.null(dbname) && dbname ==
                ":memory:") {
                dbDisconnect(connection)
            } else if (!dbPreExists && drv == "sqlite") {
                dbDisconnect(connection)
                file.remove(dbname)
            } else {
                for (nam in dfnames) dbRemoveTable(connection,
                  nam)
                for (fo in fileobjs) dbRemoveTable(connection,
                  fo)
                dbDisconnect(connection)
            }
        })
        if (request.close) {
            if (identical(connection, getOption("sqldf.connection")))
                options(sqldf.connection = NULL)
            return()
        }
    }
    if (request.open || request.nocon) {
        if (is.null(drv)) {
            drv <- if ("package:RpgSQL" %in% search()) {
                "pgSQL"
            }
            else if ("package:RMySQL" %in% search()) {
                "MySQL"
            }
            else if ("package:RH2" %in% search()) {
                "H2"
            }
            else "SQLite"
        }
        drv <- tolower(drv)
        if (drv == "mysql") {
            m <- dbDriver("MySQL")
            connection <- if (missing(dbname) || dbname == ":memory:") {
                dbConnect(m)
            }
            else dbConnect(m, dbname = dbname)
            dbPreExists <- TRUE
        }
        else if (drv == "pgsql") {
            m <- dbDriver("pgSQL")
            if (missing(dbname) || is.null(dbname)) {
                dbname <- getOption("RpgSQL.dbname")
                if (is.null(dbname))
                  dbname <- "test"
            }
            connection <- dbConnect(m, dbname = dbname)
            dbPreExists <- TRUE
        }
        else if (drv == "h2") {
            m <- H2()
            if (missing(dbname) || is.null(dbname))
                dbname <- ":memory:"
            dbPreExists <- dbname != ":memory:" && file.exists(dbname)
            connection <- if (missing(dbname) || dbname == ":memory:") {
                dbConnect(m, "jdbc:h2:mem:", "sa", "")
            }
            else {
                jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
                dbConnect(m, jdbc.string)
            }
        }
        else {
            m <- dbDriver("SQLite")
            if (missing(dbname))
                dbname <- ":memory:"
            dbPreExists <- dbname != ":memory:" && file.exists(dbname)
            if (is.null(getOption("sqldf.dll"))) {
                dll <- Sys.which("libspatialite-1.dll")
                if (dll != "")
                  options(sqldf.dll = dll)
                else options(sqldf.dll = FALSE)
            }
            dll <- getOption("sqldf.dll")
            if (length(dll) != 1 || identical(dll, FALSE) ||
                nchar(dll) == 0) {
                dll <- FALSE
            }
            else {
                if (dll == basename(dll))
                  dll <- Sys.which(dll)
            }
            options(sqldf.dll = dll)
            if (!identical(dll, FALSE)) {
                connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
                s <- sprintf("select load_extension('%s')", dll)
                dbGetQuery(connection, s)
            }
            else connection <- dbConnect(m, dbname = dbname)
            init_extensions(connection)
        }
        attr(connection, "dbPreExists") <- dbPreExists
        if (missing(dbname) && drv == "sqlite")
            dbname <- ":memory:"
        attr(connection, "dbname") <- dbname
        if (request.open) {
            options(sqldf.connection = connection)
            return(connection)
        }
    }
    if (request.con) {
        drv <- if (inherits(connection, "pgSQLConnection"))
            "pgSQL"
        else if (inherits(connection, "MySQLConnection"))
            "MySQL"
        else if (inherits(connection, "H2Connection"))
            "H2"
        else "SQLite"
        drv <- tolower(drv)
        dbPreExists <- attr(connection, "dbPreExists")
    }
    words. <- words <- strapply(x, "[[:alnum:]._]+")
    if (length(words) > 0)
        words <- unique(unlist(words))
    is.special <- sapply(mget(words, envir, "any", NA, inherits = TRUE),
        function(x) is.data.frame(x) + 2 * inherits(x, "file"))
    dfnames <- words[is.special == 1]
    for (i in seq_along(dfnames)) {
        nam <- dfnames[i]
        if (dbPreExists && !overwrite && dbExistsTable(connection,
            nam)) {
            dfnames <- head(dfnames, i - 1)
            stop(paste("sqldf:", "table", nam, "already in",
                dbname, "\n"))
        }
        nam2 <- if (drv == "h2") {
            nam
        }
        else if (drv == "pgsql") {
            nam
        }
        else {
            if (regexpr(".", nam, fixed = TRUE)) {
                paste("`", nam, "`", sep = "")
            }
            else nam
        }
        dbWriteTable(connection, nam2, as.data.frame(get(nam,
            envir)), row.names = row.names)
    }
    fileobjs <- if (is.null(file.format)) {
        character(0)
    }
    else {
        eol <- if (.Platform$OS == "windows")
            "\r\n"
        else "\n"
        words[is.special == 2]
    }
    for (i in seq_along(fileobjs)) {
        fo <- fileobjs[i]
        Filename <- summary(get(fo, envir))$description
        if (dbPreExists && !overwrite && dbExistsTable(connection,
            Filename)) {
            fileobjs <- head(fileobjs, i - 1)
            stop(paste("sqldf:", "table", fo, "from file", Filename,
                "already in", dbname, "\n"))
        }
        args <- c(list(conn = connection, name = fo, value = Filename),
            modifyList(list(eol = eol), file.format))
        args <- modifyList(args, as.list(attr(get(fo, envir),
            "file.format")))
        filter <- args$filter
        if (!is.null(filter)) {
            args$filter <- NULL
            Filename.tmp <- tempfile()
            args$value <- Filename.tmp
            cmd <- sprintf("%s < %s > %s", filter, Filename,
                Filename.tmp)
            if (.Platform$OS == "windows") {
                cmd <- paste("cmd /c", cmd)
                if (FALSE) {
                  key <- "SOFTWARE\\R-core"
                  show.error.messages <- getOption("show.error.message")
                  options(show.error.messages = FALSE)
                  reg <- try(readRegistry(key, maxdepth = 3)$Rtools$InstallPath)
                  reg <- NULL
                  options(show.error.messages = show.error.messages)
                  if (!is.null(reg) && !inherits(reg, "try-error")) {
                    Rtools.path <- file.path(reg, "bin", fsep = "\\")
                    path <- Sys.getenv("PATH")
                    on.exit(Sys.setenv(PATH = path), add = TRUE)
                    path.new <- paste(path, Rtools.path, sep = ";")
                    Sys.setenv(PATH = path.new)
                  }
                }
            }
            system(cmd)
        }
        do.call("dbWriteTable", args)
    }
    if (drv == "sqlite") {
        for (xi in x) rs <- dbGetQuery(connection, xi)
    }
    else {
        for (i in seq_along(x)) {
            if (length(words.[[i]]) > 0) {
                dbGetQueryWords <- c("select", "show", "call",
                  "explain")
                if (tolower(words.[[i]][1]) %in% dbGetQueryWords) {
                  rs <- dbGetQuery(connection, x[i])
                }
                else {
                  rs <- dbSendUpdate(connection, x[i])
                }
            }
        }
    }
    if (is.null(method))
        method <- "auto"
    if (match.arg(method, c("auto", "raw")) == "raw")
        return(rs)
    rs <- if ("row_names" %in% names(rs)) {
        if (identical(row.names, FALSE)) {
            rs[names(rs) != "row_names"]
        }
        else {
            rn <- rs$row_names
            rs <- rs[names(rs) != "row_names"]
            if (all(regexpr("^[[:digit:]]*$", rn) > 0))
                rn <- as.integer(rn)
            rownames(rs) <- rn
            rs
        }
    }
    else rs
    tab <- do.call("rbind", lapply(dfnames, function(dfname) {
        df <- get(dfname, envir)
        cbind(dfname, colnames(df))
    }))
    dup <- tab[, 2][duplicated(tab[, 2])]
    f <- function(i) {
        cn <- colnames(rs)[[i]]
        if (!cn %in% dup && (ix <- match(cn, tab[, 2], nomatch = 0)) >
            0) {
            df <- get(tab[ix, 1], envir)
            if (inherits(df[[cn]], "ordered"))
                return(as.ordered(factor(rs[[cn]], levels = levels(df[[cn]]))))
            else if (inherits(df[[cn]], "factor"))
                return(factor(rs[[cn]], levels = levels(df[[cn]])))
            else if (inherits(df[[cn]], "POSIXct"))
                return(as.POSIXct(rs[[cn]]))
            else if (identical(class(df[[cn]]), "times"))
                return(times(df[[cn]]))
            else {
                asfn <- paste("as", class(df[[cn]]), sep = ".")
                asfn <- match.fun(asfn)
                return(asfn(rs[[cn]]))
            }
        }
        if (stringsAsFactors)
            if (is.character(rs[[i]]))
                factor(rs[[i]])
            else rs[[i]]
    }
    rs2 <- lapply(seq_along(rs), f)
    rs[] <- rs2
    rs
}
Browse[2]>    
Browse[2]>    
Browse[2]>
debug: as.POSIXct.character <- function(x) structure(as.numeric(x),
    class = c("POSIXt", "POSIXct"))
Browse[2]>
debug: as.Date.character <- function(x) structure(as.numeric(x), class = "Date")
Browse[2]>
debug: as.Date.numeric <- function(x, origin = "1970-01-01", ...) base::as.Date.numeric(x,
    origin = origin, ...)
Browse[2]>
debug: as.dates.character <- function(x) structure(as.numeric(x), class = c("dates",
    "times"))
Browse[2]>
debug: as.times.character <- function(x) structure(as.numeric(x), class = "times")
Browse[2]>
debug: overwrite <- FALSE
Browse[2]>
debug: request.open <- missing(x) && is.null(connection)
Browse[2]>
debug: request.close <- missing(x) && !is.null(connection)
Browse[2]>
debug: request.con <- !missing(x) && !is.null(connection)
Browse[2]>
debug: request.nocon <- !missing(x) && is.null(connection)
Browse[2]>
debug: dfnames <- fileobjs <- character(0)
Browse[2]>
debug: if (request.close || request.nocon) {
    on.exit({
        dbPreExists <- attr(connection, "dbPreExists")
        dbname <- attr(connection, "dbname")
        if (!missing(dbname) && !is.null(dbname) && dbname ==
            ":memory:") {
            dbDisconnect(connection)
        } else if (!dbPreExists && drv == "sqlite") {
            dbDisconnect(connection)
            file.remove(dbname)
        } else {
            for (nam in dfnames) dbRemoveTable(connection, nam)
            for (fo in fileobjs) dbRemoveTable(connection, fo)
            dbDisconnect(connection)
        }
    })
    if (request.close) {
        if (identical(connection, getOption("sqldf.connection")))
            options(sqldf.connection = NULL)
        return()
    }
}
Browse[2]>
debug: {
    on.exit({
        dbPreExists <- attr(connection, "dbPreExists")
        dbname <- attr(connection, "dbname")
        if (!missing(dbname) && !is.null(dbname) && dbname ==
            ":memory:") {
            dbDisconnect(connection)
        } else if (!dbPreExists && drv == "sqlite") {
            dbDisconnect(connection)
            file.remove(dbname)
        } else {
            for (nam in dfnames) dbRemoveTable(connection, nam)
            for (fo in fileobjs) dbRemoveTable(connection, fo)
            dbDisconnect(connection)
        }
    })
    if (request.close) {
        if (identical(connection, getOption("sqldf.connection")))
            options(sqldf.connection = NULL)
        return()
    }
}
Browse[2]>
debug: on.exit({
    dbPreExists <- attr(connection, "dbPreExists")
    dbname <- attr(connection, "dbname")
    if (!missing(dbname) && !is.null(dbname) && dbname == ":memory:") {
        dbDisconnect(connection)
    } else if (!dbPreExists && drv == "sqlite") {
        dbDisconnect(connection)
        file.remove(dbname)
    } else {
        for (nam in dfnames) dbRemoveTable(connection, nam)
        for (fo in fileobjs) dbRemoveTable(connection, fo)
        dbDisconnect(connection)
    }
})
Browse[2]>
debug: if (request.close) {
    if (identical(connection, getOption("sqldf.connection")))
        options(sqldf.connection = NULL)
    return()
}
Browse[2]>
debug: NULL
Browse[2]>
debug: if (request.open || request.nocon) {
    if (is.null(drv)) {
        drv <- if ("package:RpgSQL" %in% search()) {
            "pgSQL"
        }
        else if ("package:RMySQL" %in% search()) {
            "MySQL"
        }
        else if ("package:RH2" %in% search()) {
            "H2"
        }
        else "SQLite"
    }
    drv <- tolower(drv)
    if (drv == "mysql") {
        m <- dbDriver("MySQL")
        connection <- if (missing(dbname) || dbname == ":memory:") {
            dbConnect(m)
        }
        else dbConnect(m, dbname = dbname)
        dbPreExists <- TRUE
    }
    else if (drv == "pgsql") {
        m <- dbDriver("pgSQL")
        if (missing(dbname) || is.null(dbname)) {
            dbname <- getOption("RpgSQL.dbname")
            if (is.null(dbname))
                dbname <- "test"
        }
        connection <- dbConnect(m, dbname = dbname)
        dbPreExists <- TRUE
    }
    else if (drv == "h2") {
        m <- H2()
        if (missing(dbname) || is.null(dbname))
            dbname <- ":memory:"
        dbPreExists <- dbname != ":memory:" && file.exists(dbname)
        connection <- if (missing(dbname) || dbname == ":memory:") {
            dbConnect(m, "jdbc:h2:mem:", "sa", "")
        }
        else {
            jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
            dbConnect(m, jdbc.string)
        }
    }
    else {
        m <- dbDriver("SQLite")
        if (missing(dbname))
            dbname <- ":memory:"
        dbPreExists <- dbname != ":memory:" && file.exists(dbname)
        if (is.null(getOption("sqldf.dll"))) {
            dll <- Sys.which("libspatialite-1.dll")
            if (dll != "")
                options(sqldf.dll = dll)
            else options(sqldf.dll = FALSE)
        }
        dll <- getOption("sqldf.dll")
        if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) ==
            0) {
            dll <- FALSE
        }
        else {
            if (dll == basename(dll))
                dll <- Sys.which(dll)
        }
        options(sqldf.dll = dll)
        if (!identical(dll, FALSE)) {
            connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
            s <- sprintf("select load_extension('%s')", dll)
            dbGetQuery(connection, s)
        }
        else connection <- dbConnect(m, dbname = dbname)
        init_extensions(connection)
    }
    attr(connection, "dbPreExists") <- dbPreExists
    if (missing(dbname) && drv == "sqlite")
        dbname <- ":memory:"
    attr(connection, "dbname") <- dbname
    if (request.open) {
        options(sqldf.connection = connection)
        return(connection)
    }
}
Browse[2]>
debug: {
    if (is.null(drv)) {
        drv <- if ("package:RpgSQL" %in% search()) {
            "pgSQL"
        }
        else if ("package:RMySQL" %in% search()) {
            "MySQL"
        }
        else if ("package:RH2" %in% search()) {
            "H2"
        }
        else "SQLite"
    }
    drv <- tolower(drv)
    if (drv == "mysql") {
        m <- dbDriver("MySQL")
        connection <- if (missing(dbname) || dbname == ":memory:") {
            dbConnect(m)
        }
        else dbConnect(m, dbname = dbname)
        dbPreExists <- TRUE
    }
    else if (drv == "pgsql") {
        m <- dbDriver("pgSQL")
        if (missing(dbname) || is.null(dbname)) {
            dbname <- getOption("RpgSQL.dbname")
            if (is.null(dbname))
                dbname <- "test"
        }
        connection <- dbConnect(m, dbname = dbname)
        dbPreExists <- TRUE
    }
    else if (drv == "h2") {
        m <- H2()
        if (missing(dbname) || is.null(dbname))
            dbname <- ":memory:"
        dbPreExists <- dbname != ":memory:" && file.exists(dbname)
        connection <- if (missing(dbname) || dbname == ":memory:") {
            dbConnect(m, "jdbc:h2:mem:", "sa", "")
        }
        else {
            jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
            dbConnect(m, jdbc.string)
        }
    }
    else {
        m <- dbDriver("SQLite")
        if (missing(dbname))
            dbname <- ":memory:"
        dbPreExists <- dbname != ":memory:" && file.exists(dbname)
        if (is.null(getOption("sqldf.dll"))) {
            dll <- Sys.which("libspatialite-1.dll")
            if (dll != "")
                options(sqldf.dll = dll)
            else options(sqldf.dll = FALSE)
        }
        dll <- getOption("sqldf.dll")
        if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) ==
            0) {
            dll <- FALSE
        }
        else {
            if (dll == basename(dll))
                dll <- Sys.which(dll)
        }
        options(sqldf.dll = dll)
        if (!identical(dll, FALSE)) {
            connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
            s <- sprintf("select load_extension('%s')", dll)
            dbGetQuery(connection, s)
        }
        else connection <- dbConnect(m, dbname = dbname)
        init_extensions(connection)
    }
    attr(connection, "dbPreExists") <- dbPreExists
    if (missing(dbname) && drv == "sqlite")
        dbname <- ":memory:"
    attr(connection, "dbname") <- dbname
    if (request.open) {
        options(sqldf.connection = connection)
        return(connection)
    }
}
Browse[2]>
debug: if (is.null(drv)) {
    drv <- if ("package:RpgSQL" %in% search()) {
        "pgSQL"
    }
    else if ("package:RMySQL" %in% search()) {
        "MySQL"
    }
    else if ("package:RH2" %in% search()) {
        "H2"
    }
    else "SQLite"
}
Browse[2]>
debug: {
    drv <- if ("package:RpgSQL" %in% search()) {
        "pgSQL"
    }
    else if ("package:RMySQL" %in% search()) {
        "MySQL"
    }
    else if ("package:RH2" %in% search()) {
        "H2"
    }
    else "SQLite"
}
Browse[2]>
debug: drv <- if ("package:RpgSQL" %in% search()) {
    "pgSQL"
} else if ("package:RMySQL" %in% search()) {
    "MySQL"
} else if ("package:RH2" %in% search()) {
    "H2"
} else "SQLite"
Browse[2]>
debug: if ("package:RMySQL" %in% search()) {
    "MySQL"
} else if ("package:RH2" %in% search()) {
    "H2"
} else "SQLite"
Browse[2]>
debug: if ("package:RH2" %in% search()) {
    "H2"
} else "SQLite"
Browse[2]>
debug: [1] "SQLite"
Browse[2]>
debug: drv <- tolower(drv)
Browse[2]>
debug: if (drv == "mysql") {
    m <- dbDriver("MySQL")
    connection <- if (missing(dbname) || dbname == ":memory:") {
        dbConnect(m)
    }
    else dbConnect(m, dbname = dbname)
    dbPreExists <- TRUE
} else if (drv == "pgsql") {
    m <- dbDriver("pgSQL")
    if (missing(dbname) || is.null(dbname)) {
        dbname <- getOption("RpgSQL.dbname")
        if (is.null(dbname))
            dbname <- "test"
    }
    connection <- dbConnect(m, dbname = dbname)
    dbPreExists <- TRUE
} else if (drv == "h2") {
    m <- H2()
    if (missing(dbname) || is.null(dbname))
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    connection <- if (missing(dbname) || dbname == ":memory:") {
        dbConnect(m, "jdbc:h2:mem:", "sa", "")
    }
    else {
        jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
        dbConnect(m, jdbc.string)
    }
} else {
    m <- dbDriver("SQLite")
    if (missing(dbname))
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    if (is.null(getOption("sqldf.dll"))) {
        dll <- Sys.which("libspatialite-1.dll")
        if (dll != "")
            options(sqldf.dll = dll)
        else options(sqldf.dll = FALSE)
    }
    dll <- getOption("sqldf.dll")
    if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) ==
        0) {
        dll <- FALSE
    }
    else {
        if (dll == basename(dll))
            dll <- Sys.which(dll)
    }
    options(sqldf.dll = dll)
    if (!identical(dll, FALSE)) {
        connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
        s <- sprintf("select load_extension('%s')", dll)
        dbGetQuery(connection, s)
    }
    else connection <- dbConnect(m, dbname = dbname)
    init_extensions(connection)
}
Browse[2]>
debug: if (drv == "pgsql") {
    m <- dbDriver("pgSQL")
    if (missing(dbname) || is.null(dbname)) {
        dbname <- getOption("RpgSQL.dbname")
        if (is.null(dbname))
            dbname <- "test"
    }
    connection <- dbConnect(m, dbname = dbname)
    dbPreExists <- TRUE
} else if (drv == "h2") {
    m <- H2()
    if (missing(dbname) || is.null(dbname))
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    connection <- if (missing(dbname) || dbname == ":memory:") {
        dbConnect(m, "jdbc:h2:mem:", "sa", "")
    }
    else {
        jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
        dbConnect(m, jdbc.string)
    }
} else {
    m <- dbDriver("SQLite")
    if (missing(dbname))
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    if (is.null(getOption("sqldf.dll"))) {
        dll <- Sys.which("libspatialite-1.dll")
        if (dll != "")
            options(sqldf.dll = dll)
        else options(sqldf.dll = FALSE)
    }
    dll <- getOption("sqldf.dll")
    if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) ==
        0) {
        dll <- FALSE
    }
    else {
        if (dll == basename(dll))
            dll <- Sys.which(dll)
    }
    options(sqldf.dll = dll)
    if (!identical(dll, FALSE)) {
        connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
        s <- sprintf("select load_extension('%s')", dll)
        dbGetQuery(connection, s)
    }
    else connection <- dbConnect(m, dbname = dbname)
    init_extensions(connection)
}
Browse[2]>
debug: if (drv == "h2") {
    m <- H2()
    if (missing(dbname) || is.null(dbname))
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    connection <- if (missing(dbname) || dbname == ":memory:") {
        dbConnect(m, "jdbc:h2:mem:", "sa", "")
    }
    else {
        jdbc.string <- paste("jdbc:h2", dbname, sep = ":")
        dbConnect(m, jdbc.string)
    }
} else {
    m <- dbDriver("SQLite")
    if (missing(dbname))
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    if (is.null(getOption("sqldf.dll"))) {
        dll <- Sys.which("libspatialite-1.dll")
        if (dll != "")
            options(sqldf.dll = dll)
        else options(sqldf.dll = FALSE)
    }
    dll <- getOption("sqldf.dll")
    if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) ==
        0) {
        dll <- FALSE
    }
    else {
        if (dll == basename(dll))
            dll <- Sys.which(dll)
    }
    options(sqldf.dll = dll)
    if (!identical(dll, FALSE)) {
        connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
        s <- sprintf("select load_extension('%s')", dll)
        dbGetQuery(connection, s)
    }
    else connection <- dbConnect(m, dbname = dbname)
    init_extensions(connection)
}
Browse[2]>
debug: {
    m <- dbDriver("SQLite")
    if (missing(dbname))
        dbname <- ":memory:"
    dbPreExists <- dbname != ":memory:" && file.exists(dbname)
    if (is.null(getOption("sqldf.dll"))) {
        dll <- Sys.which("libspatialite-1.dll")
        if (dll != "")
            options(sqldf.dll = dll)
        else options(sqldf.dll = FALSE)
    }
    dll <- getOption("sqldf.dll")
    if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) ==
        0) {
        dll <- FALSE
    }
    else {
        if (dll == basename(dll))
            dll <- Sys.which(dll)
    }
    options(sqldf.dll = dll)
    if (!identical(dll, FALSE)) {
        connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
        s <- sprintf("select load_extension('%s')", dll)
        dbGetQuery(connection, s)
    }
    else connection <- dbConnect(m, dbname = dbname)
    init_extensions(connection)
}
Browse[2]>
debug: m <- dbDriver("SQLite")
Browse[2]>
debug: if (missing(dbname)) dbname <- ":memory:"
Browse[2]>
debug: dbname <- ":memory:"
Browse[2]>
debug: dbPreExists <- dbname != ":memory:" && file.exists(dbname)
Browse[2]>
debug: if (is.null(getOption("sqldf.dll"))) {
    dll <- Sys.which("libspatialite-1.dll")
    if (dll != "")
        options(sqldf.dll = dll)
    else options(sqldf.dll = FALSE)
}
Browse[2]>
debug: {
    dll <- Sys.which("libspatialite-1.dll")
    if (dll != "")
        options(sqldf.dll = dll)
    else options(sqldf.dll = FALSE)
}
Browse[2]>
debug: dll <- Sys.which("libspatialite-1.dll")
Browse[2]>
debug: if (dll != "") options(sqldf.dll = dll) else options(sqldf.dll = FALSE)
Browse[2]>
debug: options(sqldf.dll = FALSE)
Browse[2]>
debug: dll <- getOption("sqldf.dll")
Browse[2]>
debug: if (length(dll) != 1 || identical(dll, FALSE) || nchar(dll) ==
    0) {
    dll <- FALSE
} else {
    if (dll == basename(dll))
        dll <- Sys.which(dll)
}
Browse[2]>
debug: {
    dll <- FALSE
}
Browse[2]>
debug: dll <- FALSE
Browse[2]>
debug: options(sqldf.dll = dll)
Browse[2]>
debug: if (!identical(dll, FALSE)) {
    connection <- dbConnect(m, dbname = dbname, loadable.extensions = TRUE)
    s <- sprintf("select load_extension('%s')", dll)
    dbGetQuery(connection, s)
} else connection <- dbConnect(m, dbname = dbname)
Browse[2]>
debug: connection <- dbConnect(m, dbname = dbname)
Browse[2]>
debug: init_extensions(connection)
Browse[2]>
debug: attr(connection, "dbPreExists") <- dbPreExists
Browse[2]>
debug: if (missing(dbname) && drv == "sqlite") dbname <- ":memory:"
Browse[2]>
debug: NULL
Browse[2]>
debug: attr(connection, "dbname") <- dbname
Browse[2]>
debug: if (request.open) {
    options(sqldf.connection = connection)
    return(connection)
}
Browse[2]>
debug: NULL
Browse[2]>
debug: if (request.con) {
    drv <- if (inherits(connection, "pgSQLConnection"))
        "pgSQL"
    else if (inherits(connection, "MySQLConnection"))
        "MySQL"
    else if (inherits(connection, "H2Connection"))
        "H2"
    else "SQLite"
    drv <- tolower(drv)
    dbPreExists <- attr(connection, "dbPreExists")
}
Browse[2]>
debug: NULL
Browse[2]>
debug: words. <- words <- strapply(x, "[[:alnum:]._]+")
Browse[2]>
Loading required package: tcltk
Loading Tcl/Tk interface ...
+
>
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sqldf hanging on macintosh - works on windows

Gabor Grothendieck
On Mon, Nov 1, 2010 at 10:55 AM, GL <[hidden email]> wrote:

>
>
>>
>> library(sqldf)
> Loading required package: DBI
> Loading required package: RSQLite
> Loading required package: RSQLite.extfuns
> Loading required package: gsubfn
> Loading required package: proto
> Loading required package: chron
>> debug(sqldf)
>>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
>> "df.possible.combos"
> +     left join "df.aggregate" using (Hour, Date)')
> debugging in: sqldf("select Date, Hour, x as RoomsInUse from
...
> debug: words. <- words <- strapply(x, "[[:alnum:]._]+")
> Browse[2]>
> Loading required package: tcltk
> Loading Tcl/Tk interface ...
> +

There is something wrong with tcltk on your system.  You can tell it
not to use tcltk by setting the appropriate option as discussed in
sqldf FAQ #5:

http://code.google.com/p/sqldf/#5._I_get_a_message_about_tcl_being_missing.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sqldf hanging on macintosh - works on windows

Marc Schwartz-3
On Nov 1, 2010, at 10:55 AM, Gabor Grothendieck wrote:

> On Mon, Nov 1, 2010 at 10:55 AM, GL <[hidden email]> wrote:
>>
>>
>>>
>>> library(sqldf)
>> Loading required package: DBI
>> Loading required package: RSQLite
>> Loading required package: RSQLite.extfuns
>> Loading required package: gsubfn
>> Loading required package: proto
>> Loading required package: chron
>>> debug(sqldf)
>>>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
>>> "df.possible.combos"
>> +     left join "df.aggregate" using (Hour, Date)')
>> debugging in: sqldf("select Date, Hour, x as RoomsInUse from
> ...
>> debug: words. <- words <- strapply(x, "[[:alnum:]._]+")
>> Browse[2]>
>> Loading required package: tcltk
>> Loading Tcl/Tk interface ...
>> +
>
> There is something wrong with tcltk on your system.  You can tell it
> not to use tcltk by setting the appropriate option as discussed in
> sqldf FAQ #5:
>
> http://code.google.com/p/sqldf/#5._I_get_a_message_about_tcl_being_missing.


GL,

If you installed R using the OSX binary from CRAN, it does not include tcl/tk. You need to install the separate tcltk package that Simon has put together and is available from:

  http://cran.us.r-project.org/bin/macosx/tools/

You also need to have X11 installed, which is available from the OSX DVD in the Optional Installs section.

HTH,

Marc Schwartz

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sqldf hanging on macintosh - works on windows

Gabor Grothendieck
On Mon, Nov 1, 2010 at 12:10 PM, Marc Schwartz <[hidden email]> wrote:

> On Nov 1, 2010, at 10:55 AM, Gabor Grothendieck wrote:
>
>> On Mon, Nov 1, 2010 at 10:55 AM, GL <[hidden email]> wrote:
>>>
>>>
>>>>
>>>> library(sqldf)
>>> Loading required package: DBI
>>> Loading required package: RSQLite
>>> Loading required package: RSQLite.extfuns
>>> Loading required package: gsubfn
>>> Loading required package: proto
>>> Loading required package: chron
>>>> debug(sqldf)
>>>>   df.final <- sqldf('select Date, Hour, x as RoomsInUse from
>>>> "df.possible.combos"
>>> +     left join "df.aggregate" using (Hour, Date)')
>>> debugging in: sqldf("select Date, Hour, x as RoomsInUse from
>> ...
>>> debug: words. <- words <- strapply(x, "[[:alnum:]._]+")
>>> Browse[2]>
>>> Loading required package: tcltk
>>> Loading Tcl/Tk interface ...
>>> +
>>
>> There is something wrong with tcltk on your system.  You can tell it
>> not to use tcltk by setting the appropriate option as discussed in
>> sqldf FAQ #5:
>>
>> http://code.google.com/p/sqldf/#5._I_get_a_message_about_tcl_being_missing.
>
>
> GL,
>
> If you installed R using the OSX binary from CRAN, it does not include tcl/tk. You need to install the separate tcltk package that Simon has put together and is available from:
>
>  http://cran.us.r-project.org/bin/macosx/tools/
>
> You also need to have X11 installed, which is available from the OSX DVD in the Optional Installs section.
>
> HTH,
>
> Marc Schwartz
>
>
>

Note that sqldf can work without tcltk, as well.  The gsubfn package
does check for tcltk and and sets the engine to "R" rather than
"tcltk" if

capabilities()[["tcltk"]]

is FALSE.  There may be a bug in R or a problem with the installation.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
GL
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sqldf hanging on macintosh - works on windows

GL
In reply to this post by Marc Schwartz-3
Marc: Installing Simon's package worked perfectly. Thanks so much!
Loading...