Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karol-blaszczyk/c8fe880cf04894c4f54584eb92bd57b6 to your computer and use it in GitHub Desktop.
Save karol-blaszczyk/c8fe880cf04894c4f54584eb92bd57b6 to your computer and use it in GitHub Desktop.
def _save_to_database(frame, table_name):
frame.toDF().write.format("jdbc").mode('overwrite')\
.option("url", "jdbc:postgresql://{}:5432/{}".format(args['db_host'],args['db_name'])) \
.option("user", args['db_user']).option("password", args['db_password'])\
.option("truncate", "true") \
.option("dbtable", table_name).save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment