Rmysql solve dbwritetable Chinese garbled or not display problems

Source: Internet
Author: User

Direct R Language Code

Library (Rmysql)
Conn<-dbconnect (Rmysql::mysql (), host= ' 10.4.20.116 ', port=3306,dbname= ' test ', username= ' biuser ', password= ' Biuser ')
Dbsendquery (conn, ' SET NAMES GBK ')
# Build tables and insert data
T_demo<-data.frame (
A=seq (1:10),
B=LETTERS[1:10],
C=rnorm (+)) #数据库创建表dbWriteTable (conn, "T_demo", T_demo)
Dbreadtable (conn, "T_demo") #新数据data. Framet_demo_n <-Data.frame (
A=1:2,
B=c ("Chinese", "Chinese 2"),
C=c (0.012,1.22)) #如果用dbWriteTable插入会不显示dbWriteTable (conn, "T_demo", T_demo_n, Append=true) # We recommend that you write the insert using a string INTO statement insert data or use the UPDATE statement to insert data strSQL <-paste (
' INSERT into T_demo (A, B, c) values ',
Paste (sprintf ("(%i, '%s ',%f)", t_demo_n$a, t_demo_n$b,t_demo_n$c), collapse= ', '),
Sep = ') #执行SQL语句dbSendQuery (conn, strSQL) #关闭连接dbDisconnect (conn)

Rmysql solve dbwritetable Chinese garbled or not display problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.