Recent Developments in Python Database Drivers, Explained Gently
A database driver is the small library that lets your program talk to a database. Python has many of them, and the landscape has shifted in recent years. Here is a calm explainer of what changed and what it means if you are writing your first database-backed script.
The steady part: one shared shape
Most Python drivers follow a common specification called the Python Database API, written up as PEP 249. It is why code for different databases looks so similar:
conn = driver.connect(...)
cur = conn.cursor()
cur.execute("SELECT name FROM pets WHERE age > ?", (3,))
rows = cur.fetchall()
conn.close()
The placeholder symbol differs between drivers (? for sqlite3, %s for psycopg and many MySQL drivers), but the shape is the same: connect, get a cursor, execute with parameters, fetch. Learn this once and it transfers.
Change 1: psycopg 3 (first released in 2021)
psycopg is the most widely used PostgreSQL driver for Python. Version 3 is a rewrite of the long-lived psycopg2. For beginners the visible differences are small: the package is installed as psycopg instead of psycopg2, connections work nicely as context managers, and there is built-in support for asynchronous code. Many tutorials still show psycopg2, which continues to work. If you are starting fresh, either is fine; just do not mix the two names in one project.
Change 2: async drivers became common
"Async" means your program can start a database request and do other work while it waits. Web frameworks built around async, such as FastAPI, made async drivers popular. You will see names like asyncpg for PostgreSQL and aiosqlite for SQLite. Async code uses await:
rows = await conn.fetch("SELECT name FROM pets")
Should a beginner start with async? Usually not. Learn the plain, synchronous style first. Async adds new ideas, and mistakes are harder to read.
Change 3: ORMs moved to new major versions
SQLAlchemy, a popular toolkit that sits on top of drivers, released version 2.0 in early 2023 with a more consistent style. Older tutorials use the 1.x style. Both can look correct, which is confusing. Check the version a tutorial targets before copying code.
What has not changed
| Thing | Still true |
|---|---|
| Use placeholders, never paste values into SQL text | Yes, with every driver |
Close connections or use with blocks | Yes |
| Commit after changes | Yes, unless autocommit is on |
| Read the driver's own docs for placeholder style | Yes |
The first row matters most. Placeholders are what stop SQL injection, as our how-to on placeholders explains for Node.js; the idea is identical in Python.
A simple decision for your first project
- Learning SQL on your own machine: the built-in
sqlite3module. Nothing to install. - A class project on PostgreSQL: psycopg (version 3) unless your course says otherwise.
- Using a framework: whatever driver its documentation recommends.
Dating note
The release years above are from the projects' own announcements. Driver projects move fast; check their changelogs for anything newer than this page.
A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.
General commentary only: this page does not report specific news events and does not cite a survey or data source. Treat any trends described as unverified.