简体   繁体   中英

Problems Connecting to MS SQL Server Through R DBI Package

I'm trying to setup a connection to a SQL Server from my Mac using the Microsoft OBDC Driver and the DBI package.

The connection establishes, however character fields, even those that have no special characters, return garbled. The database is proprietary so I'm limited as to what actual output I can show. Numeric fields return fine.

Some other notes.

  • If I submit a query, I'm able to receive a record set using the correct table. For example the below query returns results, and the column name is correct. The data in the column is garbled
> dbGetquery(con, "Select name from tb1", n = 1)
Warning: Pending rows
              name
1     CalteMtrSeda

  • dbListTables() also returns garbled output, even though as shown above I can receive output from the table referencing it by name.
    • dbListTables() returns the correct number of tables, but the names are not intelligible.
grep("tb1", dbListTables(con), value = TRUE)
character(0)
  • Output from my con object
> con
<OdbcConnection> user@ExpectedDataBase
  Database: NameIWouldExpect
  Microsoft SQL Server Version: 13.00.1742

** Updated to include pattern.

I'm getting every other character returned. From the example above. CalteMtrSeda == CharlotteMotorSpeedway

This is the first time I've attempted to connect to this database from a Mac.

Turned out to be related to R3.6. Reverting to R3.5 fixed the issue. Link to relevant issue in odbc repo

https://github.com/r-dbi/odbc/issues/283

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM