使用SparkSql從Mysql中匯入匯出資料

2021-10-17 09:03:03 字數 760 閱讀 9728

匯入資料

//建立properties物件,配置mysql的密碼和使用者名稱

val properties =

new properties(

)properties.setproperty(

"user"

,"username"

)properties.setproperty(

"password"

,"password"

)//呼叫sparksession中的read屬性的jdbc方法, 並傳入uri,表名和proerties物件

val df: dataframe = session.read.jdbc(

,"表名"

, properties)

匯出資料

//建立properties物件,配置mysql的密碼和使用者名稱

val properties =

new properties(

)properties.setproperty(

"user"

,"username"

)properties.setproperty(

"password"

,"password"

)//呼叫df中的write屬性的jdbc方法, 並傳入uri,表名和proerties物件

df.write.jdbc(

,"表名"

, properties)

儲存等級

Uber從Postgres切換到MySQL

uber 工程師在官方部落格上描述了他們為什麼要從 postgres 切換到 mysql 資料庫。uber 的早期架構是由 python 編寫的後端應用構成,使用了 postgres 資料庫。但此後,uber 的架構發生了顯著的改變,轉變到了微服務模型和新的資料平台。以前他們使用 postgres,...

Uber從Postgres切換到MySQL

uber工程師在官方部落格上描述了他們為什麼要從 postgres 切換到 mysql 資料庫 uber的早期架構是由 python編寫的後端應用構成,使用了 postgres 資料庫。但此後,uber的架構發生了顯著的改變,轉變到了微服務模型和新的資料平台。以前他們使用 postgres,現在則改...

Spark SQL使用window進行統計

def main args array string unit 按照地市進行統計top3課程 param spark param accessdf def citytypeaccesstopnstat spark sparksession,accessdf dataframe unit 執行結果如下...