DB-API
Back to DuckDB Data Engineering Glossary
DB-API 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:
Copy code
import duckdb
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.