[R-sig-DB] dbWriteTable in RPostgreSQL can't handle date and timestamp data types.
Xiaobo Gu
gux|@obo1982 @end|ng |rom gm@||@com
Mon Mar 7 06:27:11 CET 2011
Can you implement Date and Timestamp first please?
Xiaobo Gu
On Mon, Mar 7, 2011 at 12:07 AM, Tomoaki NISHIYAMA
<tomoakin using kenroku.kanazawa-u.ac.jp> wrote:
> Hi,
>
>> I have data fram with columns of type date and timestamps, but
>> dbWriteTable create text data type columns for them both, is it a bug?
>
>
> It is just not implemented.
> The relevant code is in PostgreSQLSupport.R:
>
> ## find a suitable SQL data type for the R/S object obj
> ## TODO: Lots and lots!! (this is a very rough first draft)
> ## need to register converters, abstract out PostgreSQL and generalize
> ## to Oracle, Informix, etc. Perhaps this should be table-driven.
> ## NOTE: PostgreSQL data types differ from the SQL92 (e.g., varchar truncate
> ## trailing spaces).
> postgresqlDataType <- function(obj, ...) {
> rs.class <- data.class(obj) ## this differs in R 1.4 from older vers
> rs.mode <- storage.mode(obj)
> if(rs.class=="numeric" || rs.class == "integer"){
> sql.type <- if(rs.mode=="integer") "bigint" else "float8"
> }
> else {
> sql.type <- switch(rs.class,
> character = "text",
> logical = "bool",
> factor = "text",
> ordered = "text",
> "text")
> }
> sql.type
> }
>
>
> This is all the default conversion.
> For any other type, you need to do write respective codes.
> --
> Tomoaki NISHIYAMA
>
> Advanced Science Research Center,
> Kanazawa University,
> 13-1 Takara-machi,
> Kanazawa, 920-0934, Japan
>
>
More information about the R-sig-DB
mailing list