UnicodeEncodeError: 'ascii' codec can't encode characters in position 863-868: ordinal not in range(128)

Pythonweb2173 发布于 2019/12/04 09:40
阅读 31
收藏 0

Traceback (most recent call last):
  File "/data/python/pysql.py", line 13, in <module>
    dataframe_mysql.show()
  File "/opt/cloudera/parcels/CDH-6.3.0-1.cdh6.3.0.p0.1279813/lib/spark/python/lib/pyspark.zip/pyspark/sql/dataframe.py", line 378, in show
UnicodeEncodeError: 'ascii' codec can't encode characters in position 863-868: ordinal not in range(128)
19/12/04 09:39:49 INFO spark.SparkContext: Invoking stop() from shutdown hook
19/12/04 09:39:49 INFO server.AbstractConnector: Stopped Spark@2278d9cb{HTTP/1.1,[http/1.1]}{0.0.0.0:4041}

 

原代码:

 

from pyspark.sql import SQLContext
#from __future__ import print_function
from pyspark.sql import SparkSession
import os, time

spark = SparkSession.builder\
      .appName("test")\
      .master("local")\
      .getOrCreate()
sc = spark.sparkContext 
sqlContext = SQLContext(sc)
dataframe_mysql = sqlContext.read.format("jdbc").options(url="jdbc:mysql://xxxx:3306/modelx2?useUnicode=yes&characterEncoding=UTF-8&useSSL=false", driver="com.mysql.jdbc.Driver", dbtable="xxx", user="xxx", password="xxx").load()
dataframe_mysql.show()
print "---spark----"


 

加载中
返回顶部
顶部