RODBC sqlSave column types: how determined?
Asked Answered
P

2

5

I'm trying to understand how RODBC determines the column types of a newly created (Access) table? The R documentation of sqlSave is very cryptic: "types are selected by consulting arguments varTypes and typeInfo". And no examples for this arguments. Where can I find a better explanation?

Penurious answered 28/7, 2010 at 10:9 Comment(0)
S
2

No need to look at the sources. Use "getSqlTypeInfo(driver)" instead.

> getSqlTypeInfo("ACCESS")
$double
[1] "DOUBLE"

$integer
[1] "INTEGER"

$character
[1] "VARCHAR(255)"

$logical
[1] "varchar(5)"

> 
Sciuroid answered 15/12, 2011 at 20:1 Comment(0)
M
6

Just look at the sources of the RODBC package.

# from R/TypeInfo.R:
typesR2DBMS <-
    list(MySQL = list(double="double", integer="integer",
         character="varchar(255)", logical="varchar(5)"),
         ACCESS = list(double="DOUBLE", integer="INTEGER",
         character="VARCHAR(255)", logical="varchar(5)"),
         # etc ...
Marduk answered 28/7, 2010 at 11:7 Comment(6)
cran.r-project.org/src/contrib/RODBC_1.3-2.tar.gz, File R/TypeInfo.R, Line 41Marduk
Thanks. But I'm using Windows, my C:\Program Files\R\R-2.10.1\library\RODBC directory doesn't contains TypeInfo.R. Is there no example on the net?Penurious
You have to download the source package from the link above to view the source of TypeInfo.RMarduk
fantastic answer. I love that you pulled from the source and then gave a reference to where in the source it came from. That's excellent.Convection
str(getAnywhere(typesR2DBMS))Aubarta
How can we increase the default varchar length (without changing the source code)?Sterol
S
2

No need to look at the sources. Use "getSqlTypeInfo(driver)" instead.

> getSqlTypeInfo("ACCESS")
$double
[1] "DOUBLE"

$integer
[1] "INTEGER"

$character
[1] "VARCHAR(255)"

$logical
[1] "varchar(5)"

> 
Sciuroid answered 15/12, 2011 at 20:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.