Read SQL database table into a DataFrame. Parameters ---------- table_name : str Name of SQL table in database. index_col : string, optional, default: None Column to set as index. coerce_float : bool, default True
(
self,
table_name: str,
index_col: str | list[str] | None = None,
coerce_float: bool = True,
parse_dates=None,
columns=None,
schema: str | None = None,
chunksize: int | None = None,
dtype_backend: DtypeBackend | Literal["numpy"] = "numpy",
)
| 1681 | raise DatabaseError(f"Execution failed on sql '{sql}': {exc}") from exc |
| 1682 | |
| 1683 | def read_table( |
| 1684 | self, |
| 1685 | table_name: str, |
| 1686 | index_col: str | list[str] | None = None, |
| 1687 | coerce_float: bool = True, |
| 1688 | parse_dates=None, |
| 1689 | columns=None, |
| 1690 | schema: str | None = None, |
| 1691 | chunksize: int | None = None, |
| 1692 | dtype_backend: DtypeBackend | Literal["numpy"] = "numpy", |
| 1693 | ) -> DataFrame | Iterator[DataFrame]: |
| 1694 | """ |
| 1695 | Read SQL database table into a DataFrame. |
| 1696 | |
| 1697 | Parameters |
| 1698 | ---------- |
| 1699 | table_name : str |
| 1700 | Name of SQL table in database. |
| 1701 | index_col : string, optional, default: None |
| 1702 | Column to set as index. |
| 1703 | coerce_float : bool, default True |
| 1704 | Attempts to convert values of non-string, non-numeric objects |
| 1705 | (like decimal.Decimal) to floating point. This can result in |
| 1706 | loss of precision. |
| 1707 | parse_dates : list or dict, default: None |
| 1708 | - List of column names to parse as dates. |
| 1709 | - Dict of ``{column_name: format string}`` where format string is |
| 1710 | strftime compatible in case of parsing string times, or is one of |
| 1711 | (D, s, ns, ms, us) in case of parsing integer timestamps. |
| 1712 | - Dict of ``{column_name: arg}``, where the arg corresponds |
| 1713 | to the keyword arguments of :func:`pandas.to_datetime`. |
| 1714 | Especially useful with databases without native Datetime support, |
| 1715 | such as SQLite. |
| 1716 | columns : list, default: None |
| 1717 | List of column names to select from SQL table. |
| 1718 | schema : string, default None |
| 1719 | Name of SQL schema in database to query (if database flavor |
| 1720 | supports this). If specified, this overwrites the default |
| 1721 | schema of the SQL database object. |
| 1722 | chunksize : int, default None |
| 1723 | If specified, return an iterator where `chunksize` is the number |
| 1724 | of rows to include in each chunk. |
| 1725 | dtype_backend : {'numpy_nullable', 'pyarrow'} |
| 1726 | Back-end data type applied to the resultant :class:`DataFrame` |
| 1727 | (still experimental). If not specified, the default behavior |
| 1728 | is to not use nullable data types. If specified, the behavior |
| 1729 | is as follows: |
| 1730 | |
| 1731 | * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` |
| 1732 | * ``"pyarrow"``: returns pyarrow-backed nullable |
| 1733 | :class:`ArrowDtype` :class:`DataFrame` |
| 1734 | |
| 1735 | .. versionadded:: 2.0 |
| 1736 | |
| 1737 | Returns |
| 1738 | ------- |
| 1739 | DataFrame |
| 1740 |