Show current database user
show_current_user.RdReturn or print the current database user for a MotherDuck / DuckDB connection.
Details
This helper queries the active DB connection for the current user (via
SELECT current_user). You may either provide an existing DBI connection
via .con or provide a motherduck_token and let the function open a
short-lived connection for you. When the function opens a connection it
will close it before returning.
The function supports two output modes:
"msg"— prints a small informative message and returns the result invisibly (useful for interactive use),"arg"— returns a tibble containing thecurrent_usercolumn.
Examples
if (FALSE) { # \dontrun{
# Using an existing connection
con <- connect_to_motherduck("my_token")
show_current_user(.con = con, return = "msg")
# Let the function open a connection from a token
tbl <- show_current_user(motherduck_token = "my_token", return = "arg")
} # }