Package: dittodb 0.1.11.9000

Jonathan Keane

dittodb: A Test Environment for Database Requests

Testing and documenting code that communicates with remote databases can be painful. Although the interaction with R is usually relatively simple (e.g. data(frames) passed to and from a database), because they rely on a separate service and the data there, testing them can be difficult to set up, unsustainable in a continuous integration environment, or impossible without replicating an entire production cluster. This package addresses that by allowing you to make recordings from your database interactions and then play them back while testing (or in other contexts) all without needing to spin up or have access to the database your code would typically connect to.

Authors:Jonathan Keane [aut, cre], Mauricio Vargas [aut], Helen Miller [rev], Etienne Racine [rev]

dittodb_0.1.11.9000.tar.gz
dittodb_0.1.11.9000.zip(r-4.7)dittodb_0.1.11.9000.zip(r-4.6)dittodb_0.1.11.9000.zip(r-4.5)
dittodb_0.1.11.9000.tgz(r-4.6-any)dittodb_0.1.11.9000.tgz(r-4.5-any)
dittodb_0.1.11.9000.tar.gz(r-4.7-any)dittodb_0.1.11.9000.tar.gz(r-4.6-any)
dittodb_0.1.11.9000.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
dittodb/json (API)

# Install 'dittodb' in R:
install.packages('dittodb', repos = c('https://ropensci.r-universe.dev', 'https://cloud.r-project.org'))

Reviews:rOpenSci Software Review #366

Bug tracker:https://github.com/ropensci/dittodb/issues

Pkgdown/docs site:https://dittodb.jonkeane.com

On CRAN:

Conda:

8.40 score 85 stars 62 scripts 540 downloads 52 exports 6 dependencies

Last updated from:a9bcdfe0ab (on main). Checks:10 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK153
pkgdown docsOK178
source / vignettesOK171
linux-release-x86_64OK173
macos-release-arm64OK121
macos-oldrel-arm64OK125
windows-develOK266
windows-releaseOK255
windows-oldrelOK246
wasm-releaseOK155

Exports:.db_mock_paths.dittodb_envcapture_db_requestscheck_db_pathcheck_for_pkgclean_statementdb_mock_pathsdb_path_sanitizedbBegindbClearResultdbColumnInfodbCommitdbDisconnectdbExistsTabledbFetchdbGetInfodbGetQuerydbGetRowsAffecteddbHasCompleteddbListFieldsdbListTablesdbMockConnectdbQuoteIdentifierdbQuoteStringdbRemoveTabledbRollbackdbSendQuerydbSendStatementdbWriteTabledittodb_debug_levelexpect_sqlfetchget_dbnameget_redactorget_typehashhash_db_objectmake_pathnycflights_sqlitenycflights13_create_sqlnycflights13_create_sqliteredact_columnssanitize_table_idserialize_bit64set_dittodb_debug_levelstart_db_capturingstart_mock_dbstop_db_capturingstop_mock_dbuse_dittodbwith_mock_dbwith_mock_path

Dependencies:cliDBIdigestgluelifecyclerlang

Developing dittodb
Setting up databases | What we test | How to setup test databases locally | ☠️ What not to run ☠️ | Some of the tricky bits that dittodb uses | Recording | Using a mocked database

Last update: 2026-01-11
Started: 2020-05-03

Getting Started with dittodb
Our function mean_delays() | RMariaDB | RPostgres | RSQLite | Recording fixtures | with_mock_db() | Getting setup to use dittodb | Things to be careful about | When to call dbConnect() | Query size | Advanced uses | Specify a new path | Redacting | You, too, can write a fixture!

Last update: 2025-08-17
Started: 2020-04-24

nycflights13 data
Exploring | {nycflights13} test database | Adding {nycflights13} data to a database

Last update: 2024-04-09
Started: 2020-01-14

Readme and manuals

Help Manual

Help pageTopics
Capture and record database transactions and save them as mockscapture_db_requests capture_requests start_db_capturing stop_db_capturing
Detect if a specific SQL statement is sentexpect_sql
Methods for interacting with DB mocks instead of an actual databasedbBegin,DBIMockConnection-method dbClearResult,DBIMockResult-method dbColumnInfo,DBIMockResult-method dbCommit,DBIMockConnection-method dbDisconnect,DBIMockConnection-method dbExistsTable,DBIMockConnection,character-method dbExistsTable,DBIMockConnection,Id-method dbFetch,DBIMockResult-method dbGetInfo,DBIMockConnection-method dbGetInfo,DBIMockResult-method dbGetQuery,DBIMockRPostgreSQLConnection,character-method dbGetRowsAffected,DBIMockResult-method dbHasCompleted,DBIMockResult-method DBIMockConnection-class DBIMockResult-class dbListFields,DBIMockConnection,ANY-method dbListFields,DBIMockConnection,character-method dbListFields,DBIMockConnection,Id-method dbListTables,DBIMockConnection-method dbMockConnect dbQuoteIdentifier,DBIMockRPostgresConnection,character-method dbQuoteIdentifier,DBIMockRPostgresConnection,SQL-method dbQuoteString,DBIMockMariaDBConnection,character-method dbQuoteString,DBIMockMariaDBConnection,SQL-method dbQuoteString,DBIMockRPostgresConnection,character-method dbQuoteString,DBIMockRPostgresConnection,SQL-method dbRemoveTable,DBIMockConnection,character-method dbRollback,DBIMockConnection-method dbSendQuery,DBIMockConnection,character-method dbSendQuery,DBIMockConnection,SQL-method dbSendStatement,DBIMockConnection,character-method dbWriteTable,DBIMockConnection,character,data.frame-method fetch,DBIMockResult,ANY-method fetch,DBIMockResult,missing-method fetch,DBIMockResult-method mock-db-methods
Run DBI queries against a mocked databasemockdb start_mock_db stop_mock_db with_mock_db
An SQLite connection to a subset of nycflights13nycflights_sqlite
Create a standardised database for testingnycflights13_create_sql
Create an in-memory SQLite database for testingnycflights13_create_sqlite
Redact columns from a dataframe with the default redactorsredact_columns
Set 'dittodb''s debug levelset_dittodb_debug_level
Use 'dittodb' in your testsuse_dittodb
Run the DBI queries in an alternate mock directorywith_mock_path