Giter VIP home page Giter VIP logo

Comments (3)

m-saenger avatar m-saenger commented on June 26, 2024

Finally I used the psql command line tool as a workaround to access the Postgres DB from within a future. There is some overhead obviously (open/close connection for each request), but speed is excellent and memory usage acceptable. data.table::fread allows to read psqloutput directly into a data.table (via cmd argument). Working example: https://myweather.ch/map

Minimal example:

library(future)
library(ambiorix)
library(data.table)
plan(multisession)

app <- Ambiorix$new()

app$get("/async", function(req, res){
  future({
    q <- "SELECT something FROM somewhere;"
    cmd <- sprintf("psql -h somehost -d somedb -U someuser -w -c %s -AF,", shQuote(q))
    dat <- data.table::fread(cmd = cmd))
    # Fix column types if necessary
    res$send(dat)
  })
})
app$start()

from ambiorix.

JohnCoene avatar JohnCoene commented on June 26, 2024

@m-saenger I'm sorry I never came back to you on this issue. I've setup my company last year and it left me very little time for all open-source projects.

Has this been resolved? Have you found a solution?

from ambiorix.

m-saenger avatar m-saenger commented on June 26, 2024

No worries. I found a workaround and closed this issues a couple of days ago. See #41 (comment).

from ambiorix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.