将pysparkDataframe结果写入mysql表

lvjbypge  于 2021-06-20  发布在  Mysql
关注(0)|答案(9)|浏览(382)

我是pyspark的新手,我正在尝试将dataframe的结果写入mysql表 desc_df 是Dataframe,它使用 describe 输出低于 `+-------+

oogrdqng

oogrdqng3#

--------+ |summary| val1 | val2 | val3 | +-------+

3df52oht

3df52oht5#

--------+ | count| 17547479| 17547479| 17547477| | mean|2.0946498354549963| 1.474746257282603|1943.9881619448768| | stddev|1.7921560893864912|1.2898177241581452| 40126.73218327477| | min| 0.0| 0.0| 0.0| | max| 99.0| 60.0| 1.6240624E8| +-------+

9fkzdhlc

9fkzdhlc7#

--------+我尝试下面的代码,但它抛出错误desc_df.write.format('jdbc').options( url='jdbc:mysql://localhost:3306/test', driver='com.mysql.jdbc.Driver', dbtable='pyspark_tbl', user='root', password='pwd').mode('append').save()我面临以下错误py4j.protocol.Py4JJavaError: An error occurred while calling o235.save. : java.lang.RuntimeException: org.apache.spark.sql.execution.datasources.jdbc.DefaultSource does not allow create table as select.有人可以帮我解决这个问题。Note: I have seen many posts on this , i have tried most of them but still same result.`

相关问题