[問題] R 寫入SQL問題

作者: psinqoo (零度空間)   2016-02-18 22:24:45
- 問題: 當你想要問問題時,請使用這個類別
[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
請把以下不需要的部份刪除
使用者(已經有用R 做過不少作品)
[問題敘述]:
目前 從 A 的 SQL 主機 撈資料 到 linux 上的 R 計算後
欲寫入 到 B 的 SQL 主機
遇到問題 寫入後亂碼 中文的部分
sqlSave(con, data, tablename = "table",rownames=FALSE,append=TRUE)
寫入後 情況 http://imgur.com/aXM2V2h
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
locale:
[1] LC_CTYPE=zh_TW.UTF-8 LC_NUMERIC=C
LC_TIME=zh_TW.UTF-8 LC_COLLATE=zh_TW.UTF-8 LC_MONETARY=zh_TW.UTF-8
[6] LC_MESSAGES=zh_TW.UTF-8 LC_PAPER=zh_TW.UTF-8 LC_NAME=C
LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=zh_TW.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RMySQL_0.10.6 DBI_0.3.1 RODBC_1.3-12
loaded via a namespace (and not attached):
[1] tools_3.2.2
補充
然後我試著 在我 WIN 機器上 撈A 計算後 寫入B 是正常可以的
win
> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Chinese (Traditional)_Taiwan.950 LC_CTYPE=Chinese
(Traditional)_Taiwan.950
[3] LC_MONETARY=Chinese (Traditional)_Taiwan.950 LC_NUMERIC=C
[5] LC_TIME=Chinese (Traditional)_Taiwan.950
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RMySQL_0.10.6 DBI_0.3.1 RODBC_1.3-12
loaded via a namespace (and not attached):
[1] tools_3.2.1
[程式範例]:
[環境敘述]:
R version 3.2.2 (2015-08-14)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
locale:
[1] LC_CTYPE=zh_TW.UTF-8 LC_NUMERIC=C
LC_TIME=zh_TW.UTF-8 LC_COLLATE=zh_TW.UTF-8 LC_MONETARY=zh_TW.UTF-8
[6] LC_MESSAGES=zh_TW.UTF-8 LC_PAPER=zh_TW.UTF-8 LC_NAME=C
LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=zh_TW.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RMySQL_0.10.6 DBI_0.3.1 RODBC_1.3-12
loaded via a namespace (and not attached):
[1] tools_3.2.2
[關鍵字]:
RODBC
SQL
編碼
選擇性,也許未來有用
作者: Wush978 (拒看低質媒體)   2016-02-18 22:26:00
UTF-8 v.s. BIG-5?
作者: psinqoo (零度空間)   2016-02-19 08:36:00
YES
作者: Wush978 (拒看低質媒體)   2016-02-19 22:10:00
那你可以試著查該資料庫有沒有設定encoding的地方看看

Links booklink

Contact Us: admin [ a t ] ucptt.com