I tried connecting to a Sybase db, using the DBI package, but queries do not return greek characters correctly.
Same for connections to SQL server. Here is an example of a dbConnect
command:
library(odbc)
con <- dbConnect(odbc::odbc(), .connection_string = "Driver={SQL Server};server=ATLAS;database=master;trusted_connection=true")
I had no problem when I used RODBC (with the same System DSN)
Table contents:
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Greek_Greece.1253 LC_CTYPE=Greek_Greece.1253 LC_MONETARY=Greek_Greece.1253 LC_NUMERIC=C
[5] LC_TIME=Greek_Greece.1253
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] odbc_1.1.1
loaded via a namespace (and not attached):
[1] bit_1.1-12 compiler_3.4.1 hms_0.3 DBI_0.7 tools_3.4.1 tibble_1.3.4 yaml_2.1.14 Rcpp_0.12.12 bit64_0.9-7
[10] blob_1.1.0 rlang_0.1.2
The server that DBD::Sybase connects to defaults to SYBASE, but can be specified in two ways. You can set the DSQUERY environement variable: Or you can pass the server name in the first argument to connect (): It is sometimes necessary (or beneficial) to specify other connection properties. Currently the following are supported:
To connect to MySQL database, you use the following syntax: You pass three parameters to the DBI->connect () method: The first one is the data source name. The database you are connecting is classicmodels.
By default DBD::Sybase (and the underlying OpenClient libraries) is limited to openening 25 simultaneous connections to one or more database servers. If you need more than 25 connections at the same time, you can use the maxConnect option to increase this number. Specify the database that should be made the default database.
You can tell Sybase (and DBD::Sybase) to ignore these sorts of errors by setting the arithabort option: See the set command in the Sybase Adaptive Server Enterprise Reference Manual for more information on the set command and on the arithabort option.
Please try setting the encoding
parameter in dbConnect()
. From ?odbc::dbConnect
encoding: The text encoding used on the Database. If the database is the same as your local encoding set to ‘""’. See ‘iconvlist()’ for a complete list of available encodings on your system. Note strings are always returned ‘UTF-8’ encoded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With