Created
          February 20, 2020 17:51 
        
      - 
      
- 
        Save ebuildy/ca963679b3d240120daa1ef1735a1df2 to your computer and use it in GitHub Desktop. 
    Write to mysql
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | //create properties object | |
| val prop = new java.util.Properties | |
| prop.setProperty("driver", "com.mysql.jdbc.Driver") | |
| prop.setProperty("user", "XXX") | |
| prop.setProperty("password", "XXXX") | |
| //jdbc mysql url - destination database is named "data" | |
| val url = "jdbc:mysql://XXXXX:3306/datahub" | |
| //write data from spark dataframe to database | |
| flatDF.write.mode("overwrite").jdbc(url, table, prop) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment