TSdbi PostgreSQL Methods

Share:

Description

Methods for TSdbi PostgreSQL time series dtabase connection.

Usage

 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
    PostgreSQL(...)
    ## S4 method for signature 'PostgreSQLConnection,missing'
TSconnect(q, dbname, host = 
       if(!is.null(Sys.getenv("PGHOST"))) Sys.getenv("PGHOST") else "localhost", ...)
    ## S4 method for signature 'character,TSPostgreSQLConnection'
TSget(serIDs, 
       con=getOption("TSconnection"), 
       TSrepresentation=getOption("TSrepresentation"),
       tf=NULL, start=tfstart(tf), end=tfend(tf), names=NULL, 
       TSdescription=FALSE, TSdoc=FALSE, TSlabel=FALSE, TSsource=TRUE,
       vintage=getOption("TSvintage"), panel=getOption("TSpanel"), ...)
    ## S4 method for signature 'ANY,character,TSPostgreSQLConnection'
TSput(x, serIDs, con, Table=NULL, 
       TSdescription.=TSdescription(x), TSdoc.=TSdoc(x), TSlabel.=TSlabel(x),
       TSsource.=TSsource(x), 
       vintage=getOption("TSvintage"), panel=getOption("TSpanel"), ...)
    ## S4 method for signature 'character,TSPostgreSQLConnection'
TSdates(serIDs, con,  
       vintage=getOption("TSvintage"), panel=getOption("TSpanel"), ...)
    ## S4 method for signature 'character,TSPostgreSQLConnection'
TSdelete(serIDs, con,  
   vintage=getOption("TSvintage"), panel=getOption("TSpanel"), ...)
    ## S4 method for signature 'character,TSPostgreSQLConnection'
TSdescription(x, con, ...)
    ## S4 method for signature 'character,TSPostgreSQLConnection'
TSdoc(x, con, ...)
    ## S4 method for signature 'character,TSPostgreSQLConnection'
TSlabel(x, con, ...)
    ## S4 method for signature 'character,TSPostgreSQLConnection'
TSsource(x, con, ...)
    ## S4 method for signature 'TSPostgreSQLConnection'
TSvintages(con)

Arguments

q

A character string indicating the query interface to use, or a database connection object.

dbname

The name of the database to which the connection should be established, omitted if q is a database connection object.

con

A database connection object.

serIDs

Character string identifiers for series to extract.

host

A character string indicating the server.

x

data series to put on the database, or a series identifier for TSdescription and TSdoc or, for print, a database connection as returned by TSconnect.

TSrepresentation

time series representation to use for the result.

names

Optional character vector to use for series names.

tf

Optional tframe to use for truncating data. (See tfwindow.)

start

Optional start date to use for truncating data. (See tfwindow.)

end

Optional end date to use for truncating data. (See tfwindow.)

TSdescription

TRUE or FALSE indicating whether description should be extracted

TSdescription.

Description to put on the database.

TSdoc

TRUE or FALSE indicating whether documentation should be extracted.

TSdoc.

Documentation to put on the database.

TSlabel

TRUE or FALSE indicating whether series label should be extracted.

TSlabel.

Short series label to put on the database.

TSsource

TRUE or FALSE indicating whether source indicator should be extracted.

TSsource.

Source indicator to put on the database.

Table

Character string indicating database table. (In TSput this is necessary if it cannot be determined automatically).

vintage

Vintage to be supplied (if supported by db).

panel

Panel to be supplied (if supported by db).

...

Arguments passed to other methodsor to RPostgreSQL::PostgreSQL

Details

These are PostgreSQL methods for TSdbi. The ... argument to TSconnect can be used to pass the user name and password information to dbConnect. See the TSdbi for details and see the vignette distributed with packageTSdata for more complete examples. Package TSsql is required for functions createTSdbTables() and removeTSdbTables(). Typically createTSdbTables() will only be done once, and the tables will not be removed. These steps are done in the example below.

Value

depends.

See Also

TSdbi-package, dbConnect, TSput

Examples

 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
    require("tfplot")
    ## Not run: 
      conInit <- RPostgreSQL::dbConnect("PostgreSQL", dbname="test")
      TSsql::createTSdbTables(conInit, index=FALSE)
      con <- TSconnect("PostgreSQL", dbname="test")
      z <- ts(rnorm(100), start=c(1975,1), frequency=12)
      seriesNames(z) <- "random1"
      if(TSexists("random1", con)) TSreplace(z, con) else
      TSput(z, con)
      z1 <- TSget("random1", con)
      tfplot(z1)
      z <- ts(matrix(rnorm(100),50,2), start=c(1975,1), frequency=4)
      seriesNames(z) <- c("random2","random3")
      if(TSexists("random2", con) |
         TSexists("random3", con) ) TSreplace(z, con) else
      TSput(z, con)
      z2 <- TSget("random2", con)
      tfplot(z2)
      TSdates("D1", con)
      TSdates("random2", con)
      TSdates(c("random1","random2","random3"), con)
      TSmeta("random2", con)
      options(TSconnection=con)
      z2 <- TSget(c("random2","random3"))
      z <- TSdates(c("D1","random2","random3"))
      print(z)
      TSmeta("random2")
      TSdelete("random1", con)
      TSdelete("random2")
      TSsql::removeTSdbTables(con,
                     yesIknowWhatIamDoing=TRUE, ToLower=TRUE) 
     
## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.