ploomber.clients.DBAPIClient

class ploomber.clients.DBAPIClient(connect_fn, connect_kwargs, split_source=None)

A client for a PEP 249 compliant client library

Parameters
  • connect_fn (callable) – The function to use to open the connection

  • connect_kwargs (dict) – Keyword arguments to pass to connect_fn

  • split_source (str, optional) – Some database drivers do not support multiple commands in a single execute statement. Use this optiion to split commands by a given character (e.g. ‘;’) and send them one at a time. Defaults to None (no splitting)

Examples

>>> from ploomber.clients import DBAPIClient
>>> import sqlite3
>>> client = DBAPIClient(sqlite3.connect, dict(database='my.db'))

Methods

close()

Close connection if there is an active one

cursor()

execute(code)

Execute code with the existing connection

close()

Close connection if there is an active one

cursor()
execute(code)

Execute code with the existing connection

Attributes

connection

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