...
Data retrieval
Access with R
Code Block |
---|
to dolibrary(RPostgreSQL) drv <- dbDriver("PostgreSQL") ## load the PostgreSQL driver con <- dbConnect(drv, dbname="ices1", host="localhost", user="postgres", password="yourpassword") ## Open a connection rs <- dbSendQuery(con, "select tempdata.adate, tempdata.temp, tempdata.cruise, tempdata.psal from tempdata") ## Submits a statement and declare variable result set (rs) df <- fetch(rs, n = -1) ## fetch all elements from the result set into a data.frame. n = number of records, n=-1 means all records dim(df) ## Check number of records head(df) ##show first lines dbDisconnect(con) ## Closes the connection dbUnloadDriver(drv) ## Frees all the resources on the driver |
Access with matlab
Install OpenearthTools. This contains an open source database acces toolbox for those who do not have a database toolbox license.
...