DEV Community

Cover image for What is a DB-API ?

What is a DB-API ?

Mahmoud EL-kariouny
Full Stack Web Developer
・1 min read

DB-API definition:

  • We will sometimes want to interact with our database and use its results in a specific programming language.

  • To build web applications or data pipelines in a specific language like (Ruby, Python, JavaScript, etc.).

  • That's where DBAPIs come in.


  • A DB-API provides a standard for one programming language (like python) to talk to a relational database server.

  • Is a low-level library for writing SQL statements that connect to a database.

  • Also known as database adapters.

  • Different DBAPIs exist for every server framework or language + database system.

  • Database adapters define a standard for using a database (with SQL) and using the results of database queries as input data in the given language.

-- Turn a selected (SELECT * from some_table;) list of rows into an array of objects in JavaScript for say a NodeJS adapter; or a list of tuples in Python for a Python adapter.

Examples across languages and server frameworks:

  • For Ruby (e.g. for Sinatra, Ruby on Rails): pg.

  • For NodeJS: node-Postgres.

  • For Python (e.g. for Flask, Django): pyscopg2.

Discussion (0)