问题描述
我正在尝试使用DBI :: dbConnect从RStudio连接到Athena,并且在打开驱动程序时遇到问题。
con <- DBI::dbConnect(
odbc::odbc(),Driver = "[Simba Athena ODBC Driver]",S3OutputLocation = "[s3://bucket-folder/]",AwsRegion = "[region]",AuthenticationType = "IAM Credentials",Schema = "[schema]",UID = rstudioapi::askForPassword("AWS Access Key"),PWD = rstudioapi::askForPassword("AWS Secret Key"))
Error: nanodbc/nanodbc.cpp:983: 00000: [unixODBC][Driver Manager]Can't open lib '[Simba Athena ODBC Driver]' : file not found
sort((unique(odbcListDrivers()[[1]])))
character(0)
似乎我的ODBC驱动程序无法访问或安装不正确,但是我无法理解原因。我已经下载了驱动程序,并且可以在我的库中看到它。
任何见识都将受到赞赏!
解决方法
函数参数看起来很奇怪。从[]
,Driver
和S3OutputLocation
中删除AwsRegion
。
我通过使用 odbc::odbcListDrivers()
验证 R 识别的驱动程序列表,然后相应地调整 Driver
参数的名称来解决。如果 R 不能确定驱动程序,在 ODBCSYSINI=/folder_that_contains_odbcinst.ini/
中设置 .Renviron
为我解决。