Python Notebooks
dbc can be installed and used directly in Python notebooks (such as Jupyter or Google Colab). Each of the following code blocks is designed to be executed as an individual cell in your notebook.
Install the dbc, adbc-driver-manager, and pyarrow packages:
Install the duckdb driver:
Note
This guide uses the DuckDB driver for simplicity.
To list all available drivers, run !dbc search.
Import the dbapi module:
Connect to a database via ADBC, create a cursor, execute queries, and fetch the result as a PyArrow Table:
with (
dbapi.connect(driver="duckdb") as con,
con.cursor() as cursor,
):
cursor.execute("CREATE TABLE IF NOT EXISTS penguins AS FROM 'https://blobs.duckdb.org/data/penguins.csv'")
cursor.execute("SELECT * FROM penguins")
table = cursor.fetch_arrow_table()
Print the table: