-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport_MySQL.R
More file actions
46 lines (31 loc) · 1.05 KB
/
import_MySQL.R
File metadata and controls
46 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# install RMySQl package
install.packages("RMySQL")
# import / use package
library(RMySQL)
# connection establish between RStudio and MySQL
dbcon<-dbConnect(MySQL(), username="root", password="", host="localhost",
port=3306, dbname="db_lawyer")
# show all tables name from the database
dbListTables(dbcon)
# show all columns name from the table
dbListFields(dbcon,"allappointments")
# show/fetch all data from the table
dbReadTable(dbcon,"allappointments")
# show/fetch all data from the table in a GUI format
appointments<-dbSendQuery(dbcon , "Select * from allappointments")
View(appointments)
# Fetching data
dbGetQuery(dbcon,"select * from lawyersignup")
dbSendQuery(dbcon,"select * from allappointments where
Appointment_date=2023-06-09")
appointment_data<-dbSendQuery(dbcon,"select * from allappointments where
Name='Ronald Walker' ")
dbFetch(appointment_data)
appointment_data
View(appointment_data)
# fetch all rows
data2<-fetch(appointments,n=-1)
data2
# fetch row no.3
data3<-fetch(appointments,n=3)
data3