get_column_info | R Documentation |
The get_column_info() retrieves the column information of the DBMS table through the tbl_bdi object of dplyr.
get_column_info(df)
df |
a tbl_dbi. |
An object of data.frame.
SQLite DBMS connected RSQLite::SQLite():
name: column name
type: data type in R
MySQL/MariaDB DBMS connected RMySQL::MySQL():
name: column name
Sclass: data type in R
type: data type of column in the DBMS
length: data length in the DBMS
Oracle DBMS connected ROracle::dbConnect():
name: column name
Sclass: column type in R
type: data type of column in the DBMS
len: length of column(CHAR/VARCHAR/VARCHAR2 data type) in the DBMS
precision: precision of column(NUMBER data type) in the DBMS
scale: decimal places of column(NUMBER data type) in the DBMS
nullOK: nullability
library(dplyr)
if (requireNamespace("DBI", quietly = TRUE) & requireNamespace("RSQLite", quietly = TRUE)) {
# connect DBMS
con_sqlite <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
# copy heartfailure to the DBMS with a table named TB_HEARTFAILURE
copy_to(con_sqlite, heartfailure, name = "TB_HEARTFAILURE", overwrite = TRUE)
con_sqlite %>%
tbl("TB_HEARTFAILURE") %>%
get_column_info() %>%
print()
# Disconnect DBMS
DBI::dbDisconnect(con_sqlite)
} else {
cat("If you want to use this feature, you need to install the 'DBI' and 'RSQLite' package.\n")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.