You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where the current user before the with block is called is reset as the user when the with block exits so that the current user can enter user or role contexts quickly and test things out
library(rls)
library(DBI)
library(RPostgres)
library(dplyr)
con<- dbConnect(Postgres())
rls_current_user(con)
dbCreateTable(con, "cars", mtcars)
rows_append(
tbl(con, "cars"),
copy_inline(con, mtcars),
in_place=TRUE
)
dbExecute(con, "CREATE ROLE analysts")
# should fail because role analysts doesn't have access to cars yet
with_db_user(
con=con,
user="analysts",
code= dbGetQuery(con, "select * from cars")
)
# back to current user
rls_current_user(con)
Idea is to:
Where the current user before the with block is called is reset as the user when the with block exits so that the current user can enter user or role contexts quickly and test things out
There is a method in
withr
for databases, https://withr.r-lib.org/reference/with_db_connection.htmlwith_db_connection
, so that may be part of the solution@seankross ?
The text was updated successfully, but these errors were encountered: