pyspark.sql.DataFrameWriter.jdbc¶
-
DataFrameWriter.
jdbc
(url, table, mode=None, properties=None)[source]¶ Saves the content of the
DataFrame
to an external database table via JDBC.Note
Don’t create too many partitions in parallel on a large cluster; otherwise Spark might crash your external database systems.
- Parameters
url – a JDBC URL of the form
jdbc:subprotocol:subname
table – Name of the table in the external database.
mode –
specifies the behavior of the save operation when data already exists.
append
: Append contents of thisDataFrame
to existing data.overwrite
: Overwrite existing data.ignore
: Silently ignore this operation if data already exists.error
orerrorifexists
(default case): Throw an exception if data already exists.
properties – a dictionary of JDBC database connection arguments. Normally at least properties “user” and “password” with their corresponding values. For example { ‘user’ : ‘SYSTEM’, ‘password’ : ‘mypassword’ }
New in version 1.4.