Connects to a MySQL or MariaDB database, executes a SQL query, and returns
the result as a tidylearn_data object. Accepts either a connection
string or individual connection parameters. Requires DBI and
RMariaDB.
Arguments
- dsn
A MySQL connection string (e.g.,
"mysql://user:pass@host:port/dbname"), or the database host if using named parameters. Percent-encode special characters in the user name and password (@as%40). Query parameters are refused, because RMariaDB ignores arguments it does not know; pass itsdbConnect()arguments, such asssl.ca, through....- query
A SQL query string.
- dbname
Database name (if not in
dsn).- user
Username (if not in
dsn).- password
Password (if not in
dsn), which keeps it out of the connection string.- port
Port number (if not in
dsn). Default is 3306.- ...
Additional arguments passed to
DBI::dbConnect().
Examples
if (FALSE) { # \dontrun{
# Needs a running MySQL or MariaDB server
tl_read_mysql(
dsn = "localhost",
query = "SELECT * FROM my_table",
dbname = "mydb",
user = "myuser",
password = Sys.getenv("MYSQL_PWD")
)
} # }
