---
title: "DB-API"
description: "DB-API is a standardized interface for Python to interact with relational databases."
canonical: "https://motherduck.com/glossary/db-api/"
related:
  - title: "Why Python Developers Need DuckDB (And Not Just Another DataFrame Library)"
    url: "https://motherduck.com/blog/python-duckdb-vs-dataframe-libraries/"
  - title: "MotherDuck Interfaces | MotherDuck Docs"
    url: "https://motherduck.com/docs/getting-started/interfaces/"
  - title: "DuckLake: The Definitive Guide — Live Author Q&A with Matt Martin & Alex Monahan | MotherDuck"
    url: "https://motherduck.com/videos/ducklake-definitive-guide-oreilly-book/"
---

# DB-API

> DB-API is a standardized interface for Python to interact with relational databases.

[DB-API](https://peps.python.org/pep-0249/) is a standardized interface for Python to interact with relational databases. It defines a set of methods and behaviors that database drivers must implement, ensuring consistency across different database systems. This specification allows Python developers to write code that can work with various databases without major modifications. DB-API compliant drivers exist for many popular databases, including MySQL, PostgreSQL, and SQLite. When using DuckDB with Python, you'll often interact with it through its DB-API implementation. For example, to execute a query using DB-API:

```python
import duckdb

<glossary-callout guide="duckdb-book-brief" />

conn = duckdb.connect('mydatabase.db')
cursor = conn.cursor()
cursor.execute("SELECT * FROM mytable WHERE column1 > 5")
results = cursor.fetchall()
```

This standardization simplifies database interactions in Python and promotes code portability across different database systems.
