Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server Error: String data, right truncation #197

Open
mkaranja opened this issue Sep 20, 2024 · 0 comments
Open

SQL Server Error: String data, right truncation #197

mkaranja opened this issue Sep 20, 2024 · 0 comments

Comments

@mkaranja
Copy link

mkaranja commented Sep 20, 2024

Hello,
I have used shinymanager authentication with sqllite database but since I wasn't persistence, I want to connect to SQL Server using .yml file.

Part of .yml file connection looks like this,
// # needed R packages for DB connection. Use comma separation for multiple dependencies like [package1, package2]
r_packages: [odbc]

// optional. Default to false = connect one time per session. True = connect/disconnect each request
connect_every_request: false

// connection usong DBI Interface
// Possible to use !expr Sys.getenv("NAME_ENV_VAR")
// all args to be passed to DBI::dbConnect by default
// use fun: "connect_function_name" to use other connected functinon

connect:
  drv: !expr odbc::odbc()
  Driver: "ODBC Driver 17 for SQL Server"
  Server: "******"
  Database: "******"
  UID: "*****"
  PWD: "*****"
  port: 41433

Create SQL database

user <- data.frame(
  user = c("admin", "curator", "user"),
  password = c("pass0", "pass1", "pass2" ),
  admin = c(T,F,F)
)

shinymanager::create_sql_db(
  credentials_data = user,
  config_path = "path/to/pg_template.yml"
)

Then using a minimal shiny app to login,

library(shiny)
library(shinymanager)

ui <- fluidPage(
  tags$h2("My secure application"),
  verbatimTextOutput("auth_output")
)

ui <- secure_app(ui, choose_language = TRUE)
server <- function(input, output, session) {
  res_auth <- secure_server(
    check_credentials = check_credentials(db = "path/to/pg_template.yml")
  )
}
shinyApp(ui, server)

But I get this error when I try to login,

Listening on http://127.0.0.1:4567
Warning: Error in run_now: nanodbc/nanodbc.cpp:1783: 00000
[Microsoft][ODBC Driver 17 for SQL Server]String data, right truncation 
  70: <Anonymous>
  69: stop
  68: result_insert_dataframe [/tmp/Rtmpf9K93x/R.INSTALL3cd2513f1410/odbc/R/RcppExports.R#109]
  65: .local [/tmp/Rtmpf9K93x/R.INSTALL3cd2513f1410/odbc/R/dbi-table.R#173]
  64: dbAppendTable
  62: write_sql_db
  61: save_logs
  60: ui
   3: runApp [/tmp/Rtmp9eVnhH/R.INSTALL7cff42bb9f16/shiny/R/runapp.R#388]
   2: print.shiny.appobj [/tmp/Rtmp9eVnhH/R.INSTALL7cff42bb9f16/shiny/R/shinyapp.R#565]
   1: <Anonymous>

What could be the issue here? Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant