class ploomber.clients.Client

Abstract class for all clients

Clients are classes that communicate with another system (usually a database), they provide a thin wrapper around libraries that implement clients to avoid managing connections directly. The most common use case by far is for a Task/Product to submit some code to a system, a client just provides a way of doing so without dealing with connection details.

A Client is reponsible for making sure an open connection is available at any point (open a connection if none is available).

However, clients are not strictly necessary, a Task/Product could manage their own client connections. For example the NotebookRunner task does have a Client since it only calls an external library to run.


Method’s names were chosen to resemble the ones in the Python DB API Spec 2.0 (PEP 249)



Close connection if there is one active


Execute code

abstract close()

Close connection if there is one active

abstract execute(code)

Execute code



Return a connection, open one if there isn't any