scala – 如何将DataFrame写入MySQL表
发布时间:2020-12-16 18:09:51 所属栏目:安全 来源:网络整理
导读:很抱歉,如果它听起来模糊,但可以解释将现有的DataFrame“df”写入 MySQL表中的步骤,说“product_mysql”,反之亦然. 解决方法 请看 this databricks article : Connecting to SQL Databases using JDBC. import org.apache.spark.sql.SaveModeval df = spark.
很抱歉,如果它听起来模糊,但可以解释将现有的DataFrame“df”写入
MySQL表中的步骤,说“product_mysql”,反之亦然.
解决方法
请看
this databricks article : Connecting to SQL Databases using JDBC.
import org.apache.spark.sql.SaveMode val df = spark.table("...") println(df.rdd.partitions.length) // given the number of partitions above,users can reduce the partition value by calling coalesce() or increase it by calling repartition() to manage the number of connections. df.repartition(10).write.mode(SaveMode.Append).jdbc(jdbcUrl,"product_mysql",connectionProperties) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |