Exploring DuckDB’s Python API
In the previous chapter, we started our journey into using DuckDB and Python by getting the DuckDB Python client installed into a Jupyter Notebook-based environment, as well as unpacking the different ways to connect to DuckDB databases. In this chapter, we’ll continue where we left off by diving into a practically oriented walkthrough of the core components of the DuckDB Python API, which will enable you to hit the ground running working with DuckDB in Python.
More specifically, we’ll explore the following aspects of working with DuckDB in Python:
- Interacting with DuckDB using the Relational API
- Interacting with DuckDB using the Python DB-API
- Consuming from and converting to Python in-memory data formats, including Apache Arrow tables, pandas Dataframes, and Polars Dataframes
- How Python types are converted to DuckDB types
- Using Python functions in DuckDB queries
- Exception handling with DuckDB