Create & Connect to SQL Database in R (Example) | Access, Interface Management & Software Packages

preview_player
Показать описание

R code of this video:

library(odbc) #Contains drivers to connect to a database
library(DBI) #Contains functions for interacting with the database

con <- DBI::dbConnect(drv = odbc::odbc(),
Driver = "driver_name",
Server = "server_url",
Database = "database_name",
user = "user", #optional
password = "password") #optional

library(RSQL) #Generate and Process 'SQL' Queries in R
library(RSQLite) #Can create an in-memory SQL database
library(tidyverse) #Provides helpful functions and sample data to use in R

data("population")
population

data("who")
who

#Build the placeholder
con <- dbConnect(drv = RSQLite::SQLite(),
dbname = ":memory:")

dbListTables(con)

#Load the population table
dbWriteTable(conn = con,
name = "population",
value = population)

#Load the who table
dbWriteTable(conn = con,
name = "who",
value = who)

dbListTables(con)

res <- DBI::dbGetQuery(conn = con,
statement = "
FROM population, who
")
res

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

How can your connect to an existing database in MySQL workbench? Thanks

jamesleleji
Автор

He should have connected one for us to see😢

philanttech
Автор

this is sooo bad, your just talking about how to do it not showing

nawkee
visit shbcf.ru