pyspark.sql.DataFrameReader.jdbc¶
-
DataFrameReader.jdbc(url: str, table: str, column: Optional[str] = None, lowerBound: Union[str, int, None] = None, upperBound: Union[str, int, None] = None, numPartitions: Optional[int] = None, predicates: Optional[List[str]] = None, properties: Optional[Dict[str, str]] = None) → DataFrame¶ Construct a
DataFramerepresenting the database table namedtableaccessible via JDBC URLurland connectionproperties.Partitions of the table will be retrieved in parallel if either
columnorpredicatesis specified.lowerBound,upperBoundandnumPartitionsis needed whencolumnis specified.If both
columnandpredicatesare specified,columnwill be used.- Parameters
- tablestr
the name of the table
- columnstr, optional
alias of
partitionColumnoption. Refer topartitionColumnin Data Source Option in the version you use.- predicateslist, optional
a list of expressions suitable for inclusion in WHERE clauses; each one defines one partition of the
DataFrame- propertiesdict, optional
a dictionary of JDBC database connection arguments. Normally at least properties “user” and “password” with their corresponding values. For example { ‘user’ : ‘SYSTEM’, ‘password’ : ‘mypassword’ }
- Returns
- Other Parameters
- Extra options
For the extra options, refer to Data Source Option in the version you use.
Notes
Don’t create too many partitions in parallel on a large cluster; otherwise Spark might crash your external database systems.