Guest User

Untitled

a guest
Sep 26th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # CSCI E-63 HW3 - Problem 3
  2. # Author: Walter Yu
  3. # Description: PySpark script to connect to MySQL database, register table and display row count.
  4.  
  5. # Create context and connect to MySQL:
  6. sqlContext= SQLContext(sc)
  7. dfm = sqlc.read.format("jdbc").option("url","jdbc:mysql://localhost/retail_db").option("driver","com.mysql.jdbc.Driver").option("dbtable","departments").option("user","xxxxx").option("password","xxxxx").load()
  8.  
  9. # Verify schema, create view and display row count:
  10. dfm.printSchema()
  11. dfm.registerTempTable("departments")
  12. dfm
  13. dfm.count()
  14. dfm.collect()
Add Comment
Please, Sign In to add comment