ODBC截断varchar字段

时间:2018-01-23 00:58:15

标签: r odbc vertica

使用ODBC包连接到vertica(MAC OSX)。我已使用ODBC驱动程序和DBI包连接到vertica数据库。我能够连接到数据库。来自查询结果的varchar字段将被截断,而其他字段将被正确检索。

library(RODBC)
library(DBI)

default_vertica_database         <- 'dsciasda01'
default_vertica_user             <- 'sadasdy'
default_vertica_pass             <- 'sadasds'
default_vertica_port             <- 5433
default_vertica_hosts            <- 'vsadasdz-vip.adas.sadasda.com'

vertica_driver      <- default_vertica_driver
vertica_database    <- default_vertica_database
vertica_port        <- default_vertica_port
vertica_host        <- default_vertica_host
vertica_user        <- default_vertica_user
vertica_pass        <- default_vertica_pass

vertica_driver      <- '/Library/Vertica/ODBC/lib/libverticaodbc.dylib'

#connect to vertica
vth <- dbConnect(odbc::odbc(),
                 driver   = vertica_driver,
                 database = vertica_database,
                 uid      = vertica_user,
                 pwd      = vertica_pass,
                 host     = vertica_host,
                 port     = vertica_port
)

pool_list<<-dbGetQuery(vth, "Select * from table0.table_current limit 10")

varchar字段被截断。如果有一个长度为64的字段,则只检索字符串中的第一个字符。

1 个答案:

答案 0 :(得分:0)

可能相关 - 使用ODBC连接到Amazon的Redshift,我发现我需要在连接中设置MaxLongVarcharSize参数:

con <- dbConnect(odbc::odbc(),
                 driver = "Amazon Redshift Driver",
                 database = "xx",
                 uid = "yy",
                 pwd = "zz",
                 locale="en-US",
                 host = "aa",
                 port = 5439,
                 MaxLongVarcharSize = 8190)

h / t RODBC string getting truncated