-
Notifications
You must be signed in to change notification settings - Fork 2
/
posgre.R
32 lines (23 loc) · 1.22 KB
/
posgre.R
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
posgrefun<- function(dbname,host,port,user,password) {
library(RPostgreSQL)
# loads the PostgreSQL driver
drv <- dbDriver("PostgreSQL")
# creates a connection to the postgres database
# note that "con" will be used later in each connection to the database
con <- dbConnect(drv, dbname = dbname,
host = host, port = 5432,
user = user, password = password)
# check for the tables
meta<-dbReadTable(con, c("mb2eml_r","vw_eml_attributes"))
fact<-dbReadTable(con,c("mb2eml_r","vw_eml_attributecodedefinition"))
unit<-dbReadTable(con, c("mb2eml_r","vw_custom_units"))
creator<-dbReadTable(con, c("mb2eml_r","vw_eml_creator"))
keyword<-dbReadTable(con, c("mb2eml_r","vw_eml_keyword"))
entities<-dbReadTable(con, c("mb2eml_r","vw_eml_entities"))
dataset<-dbReadTable(con, c("mb2eml_r","vw_eml_dataset"))
method<-dbReadTable(con, c("mb2eml_r","vw_eml_datasetmethod"))
geo<-dbReadTable(con, c("mb2eml_r","vw_eml_geographiccoverage"))
tempo<-dbReadTable(con, c("mb2eml_r","vw_eml_temporalcoverage"))
dbDisconnect(con)
return (list(meta=meta,fact=fact,unit=unit,creator=creator,keyword=keyword,entities=entities,dataset=dataset,method=method,geo=geo,tempo=tempo))
}