Comments (11)
Perhaps try UTF-16? Clearly UTF-8 is not correct...
from odbc.
The single letter table names indicate that a mismatch between the encoding returned by the driver and what unixODBC is expecting.
In the amazon.redshiftodbc.ini
file, located by default in /opt/amazon/redshift/lib/amazon.redshiftodbc.ini
, you need to use the following settings
DriverManagerEncoding=UTF-8
ODBCInstLib=libodbcinst.so
You also may want to set a valid logPath
from odbc.
The amazon instructions you mention seem to be using iODBC, not unixODBC, perhaps that is part of the issue. The configuration instructions also mention modifying your LD_LIBRARY_PATH
to ensure the driver libraries are loaded properly. You should ensure this is the case, particularly if you are starting R from somewhere other than the command line (like the RStudio IDE).
Also I would suggest using exactly the same strings in the manual configuration as in your odbc.ini
, the default strings will likely not work for redshift.
A successful connection with isql should mean that odbc should also work, it is difficult to diagnose the issue without having a redshift instance to test against.
from odbc.
Thanks for the quick reply, @jimhester. I made progress by substituting in the actual path to the Amazon Redshift driver for the driver
parameter. The good news is that the connection succeeds.
However, I get bogus answers when I use the odbc
functions. I do have multiple schemas in the mortgage database; per issue #18, is there a workaround to use schema names in the odbc
functions?
> library(DBI); library(ggplot2)
> con <- dbConnect(
+ odbc::odbc(),
+ driver = "/opt/amazon/redshift/lib/libamazonredshiftodbc.dylib",
+ servername = "mortgage.shared-vault.com", database = "mortgage",
+ UserName = "xxx", Password = "yyy", port = 5439
+ )
> dbListTables(con)
[1] "c" "c" "d" "d" "g" "g" "l" "l" "l" "p" "a" "a" "c" "d" "e"
[16] "e" "h" "h" "l" "l" "l" "o" "p" "p" "p" "r" "s" "c" "f" "c"
[31] "i" "l" "l" "q" "s" "h" "h" "f" "p" "s" "s" "t" "l" "l" "s"
[46] "v" "i" "i" "i" "i" "i" "m" "m" "m" "m" "m" "z" "c" "l" "c"
[61] "c" "d" "d" "d" "g" "l" "l" "l" "l" "a" "f" "h" "h" "h" "h"
[76] "h" "h" "p" "p"
> dbListTables(con, table_name = "f%")
[1] "f" "f" "f"
> mpg_table <- dbWriteTable(con, "mpg", mpg)
Error in new_result(connection@ptr, statement) :
nanodbc.cpp:1587: 42501: [Amazon][Amazon Redshift] (30) Error occurred while trying to execute a query: [SQLState 42501] ERROR: permission denied for schema cfpb_hmda
from odbc.
Hmm. I edited /opt/amazon/redshift/lib/amazon.redshiftodbc.ini
.
[Driver]
## - Note that this default DriverManagerEncoding of UTF-32 is for iODBC.
# DriverManagerEncoding=UTF-32
DriverManagerEncoding=UTF-8
ErrorMessagesPath=/opt/amazon/redshift/ErrorMessages
LogPath=[LogPath]
SwapFilePath=/tmp
# iODBC
# ODBCInstLib=libiodbcinst.dylib
ODBCInstLib=libodbcinst.so
I then got this output. 😄 Any ideas?
> dbListTables(con)
[1] "畣楳彰楬歮"
[2] "畣楳彰楬歮慟汬损獵灩"
...
from odbc.
UTF-16 worked like a charm; awesome!!!
If I need to read or write to a specific schema, is that possible?
from odbc.
I need to look into schema support a bit more I think, but you can always fall back to writing the SQL by hand if needed and passing it to dbGetQuery()
.
from odbc.
Sounds good; thanks for all your help!
from odbc.
I have the same issue with Athena. Any idea?
from odbc.
I have the same issue with Athena. Any idea?
Perhaps try UTF-16 (as jimhester has recommended)
from odbc.
I have the same issue with Athena. Any idea?
Perhaps try UTF-16 (as jimhester has recommended)
Indeed it worked!
from odbc.
Related Issues (20)
- In the latest version of odbc, temporary db tables are visible across sessions. HOT 1
- `dbWriteTable()` requires `row.names` argument HOT 3
- Empty `con@info$username` HOT 6
- Update issue template? HOT 1
- Run DBI tests for Oracle
- SQL Server error messages do not always lead to errors in R HOT 7
- `dbExecute()` doesn't return the number of rows affected with Oracle HOT 9
- unable to find an inherited method for function ‘dbExistsTable’ for signature ‘"Microsoft SQL Server", "NULL"’ HOT 4
- Release odbc 1.4.2
- revisit Impala binary type HOT 1
- DBI::dBDisconnect() with ms-access HOT 1
- Mutex error only when attempting to read/write HOT 4
- Default to arbitrary database if not specified when creating temp tables on a warehouse (Snowflake / Databricks) HOT 6
- restore docs on `ODBCSYSINI` and `ODBCINI`
- id_field maybe should use names provided by DBI::Id instead of using order? HOT 1
- Variable type not bound when using prepared queries HOT 3
- SQL Server: dbListFields fails when name is an Id
- Add support for `dsn` argument to `databricks()` HOT 1
- Include synonyms in `odbcListObjects()`, `dbListTables()`, and the Connections Pane HOT 1
- Connection from RStudio to Snowflake throws error about odbcListObjects HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odbc.