pachadotdev / tradestatistics-plumber-api

tradestatistics.io API, reads from PostgreSQL and provides tidy CSV and Apache Arrow data
https://api.tradestatistics.io/
Apache License 2.0
2 stars 1 forks source link

DB finally running, now I can't make plumber work #1

Closed pachadotdev closed 5 years ago

pachadotdev commented 5 years ago

Hi !!

The server now has the full DB and I installed both RStudio Server and these R packages as root (so those are available for all users):

The script on this repo was an attempt to run an SQL query and convert the result to JSON. My 1st test was:

> library(plumber)
> api <- plumb("api.R")
Loading required package: DBI
> api$run(port = 8000)
Starting server to listen on port 8000
Running the swagger UI at http://127.0.0.1:8000/__swagger__/

The output returns:

pacha@tradestatistics:~$ curl "http://localhost:8000/echo"
{"msg":["The message is: ''"]}
pacha@tradestatistics:~$ curl "http://localhost:8000/yrpc?y=2015"
["{}"]

while RStudio returns:

Error in postgresqlExecStatement(conn, statement, ...) : 
  RS-DBI driver: (could not Retrieve the result : ERROR:  invalid byte sequence for encoding "UTF8": 0xb9
)
Warning in postgresqlQuickSQL(conn, statement, ...) :
  Could not create execute: 

Can you give me a hand? You can always go to data.local:8787 and open RStudio Server :)

aedobbyn commented 5 years ago

I wasn't able to connect to the db using a dbusr of either "amanda/jorge/joshua" or just "amanda".

Error in postgresqlNewConnection(drv, ...) : 
  RS-DBI driver: (could not connect amanda@data.local:5432 on dbname "trade_statistics": FATAL:  password authentication failed for user "amanda"
)

Any ideas?

As for the error you're getting, I'm not totally sure but you might try using glue::glue_sql instead of sprintf to avoid any encoding errors.

pachadotdev commented 5 years ago

Hi @aedobbyn Thanks for the prompt reply!! On this repo I have a .Renviron file that I didn't upload, this is the content of that file:

dbusr="amanda"
dbpwd="YOUR_PASSWORD"
dbhost="localhost"
dbname="trade_statistics"
pachadotdev commented 5 years ago

@aedobbyn glue works !!!!!!!!!!! thanks a lot for the suggestion

image

pachadotdev commented 5 years ago

@aedobbyn I just double checked your permissions again, it should work now

aedobbyn commented 5 years ago

These creds seem to be referencing a local copy of the database, which I don't have -- shouldn't we be accessing the remote db?

pachadotdev commented 5 years ago

You're right! I was able to connect to the DB in the server with all users from my laptop by using datagrip Just in case I reseted the passwords Please let me know if it works

On Sun, Dec 16, 2018, 2:20 PM Amanda Dobbyn <notifications@github.com wrote:

These creds seem to be referencing a local copy of the database, which I don't have -- shouldn't we be accessing the remote db?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/tradestatistics/ts-plumber-api/issues/1#issuecomment-447660242, or mute the thread https://github.com/notifications/unsubscribe-auth/AJn6OdMNVtiMoWwJmK5aursi8W2oj-Ooks5u5oDhgaJpZM4ZSS7L .