pyspark.pandas.
read_sql_query
Read SQL query into a DataFrame.
Returns a DataFrame corresponding to the result set of the query string. Optionally provide an index_col parameter to use one of the columns as the index, otherwise default index will be used.
Note
Some database might hit the issue of Spark: SPARK-27596
SQL query to be executed.
A JDBC URI could be provided as str.
The URI must be JDBC URI instead of Python’s database URI.
Column(s) to set as index(MultiIndex).
All other options passed directly into Spark’s JDBC data source.
See also
read_sql_table
Read SQL database table into a DataFrame.
read_sql
Examples
>>> ps.read_sql_query('SELECT * FROM table_name', 'jdbc:postgresql:db_name')