Briefing: What a Database Driver Does, in One Page

"Which driver are we using?" is a question that confuses many beginners. This one-page brief explains what a driver is, why it matters and what to check, in plain language.

The issue

Your app is written in a programming language such as Python, JavaScript, Java or C#. Your database speaks its own network language, called a protocol. A database driver is a library that sits between the two. It opens the connection, sends your SQL, and turns the database's replies back into values your program understands, such as lists, numbers and dates.

Your code  ->  driver  ->  network  ->  database
Your code  <-  driver  <-  network  <-  results

Without a driver, your program has no way to talk to the database.

Why it matters

Examples by language

LanguageTypical drivers
Pythonsqlite3 (built in), psycopg for PostgreSQL, several MySQL drivers
JavaScript (Node.js)pg for PostgreSQL, mysql2 for MySQL, better-sqlite3 for SQLite
JavaJDBC drivers supplied for each database
C# / .NETADO.NET providers such as Npgsql or Microsoft.Data.SqlClient

Frameworks and ORMs, such as Django or Entity Framework, use a driver underneath. You may never call the driver directly, but it is still there.

Three takeaways

  1. Use the driver your database or framework recommends. Official or widely used drivers are better maintained and better documented.
  2. Keep it up to date. Drivers receive security and bug fixes like any other software.
  3. Read its connection-string and placeholder docs once. Most beginner errors, like "wrong number of parameters" or "connection refused", come down to these two topics.

Questions to ask

Further reading on this site

A common beginner mix-up

People often confuse the driver with the database itself, or with the tool they use to look at data. They are three different things. The database server stores the data and runs the queries. A client tool, such as the psql command line or a graphical browser, is a program for people to type queries by hand. The driver is a library for programs, so your code can do what you would otherwise type yourself. Installing PostgreSQL does not automatically install a Python driver for it, and installing a driver does not give you a database. When a tutorial says "install the driver", it means the library for your programming language, usually through a package manager such as pip or npm.

When you are ready for performance topics such as connection pools and timeouts, our sister site databaseintegrate.com covers them for working developers.

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.