MyNixOS website logo
Description

Easily Connect to Common Types of Databases.

A unified interface for connecting to databases ('SQLite', 'MySQL', 'PostgreSQL'). Just provide the database name and the package will ask you questions to help you configure the connection and setup your credentials. Once database configuration and connection has been set up once, you won't have to do it ever again.

easydb

Lifecycle:experimental CRANstatus R-CMD-check DownloadStats

The goal of easydb is to simplify the process of connecting to databases using R

Installation

Install from CRAN

install.packages('easydb')

You can install the development version of easydb like so:

# install.packages('remotes')
remotes::install_github('selkamand/easydb')

Quick start (examples)

library(easydb)

# Initialise a config file at '~/.easydb'
easydb_init(config_file = '~/.easydb')

# sqlite
sqlitedb <- system.file(package="easydb", "testdbs/mtcars.sqlite")
sqlite_connection <- easydb_connect(sqlitedb, config_file = '~/.easydb')

# mysql
# Example: connect to the public rfam mysql database
#
# See here for connection configuration: 
# https://docs.rfam.org/en/latest/database.html
rfam_connection <- easydb_connect(dbname = "Rfam", config_file = '~/.easydb')


# postgresql
# Example: Connect to public RNAcentral postgres database
#
# See here for connection configuration: 
# https://rnacentral.org/help/public-database
rna_central_connection <- easydb_connect(dbname = 'pfmegrnargs', config_file = '~/.easydb')


# Don't forget to disconnect from databases when you finish!
easydb_disconnect(sqlite_connection)
easydb_disconnect(rna_central_connection)
easydb_disconnect(rfam_connection)

Disconnect

Once you’ve finished working with a database, its best to disconnect from the db using easydb_disconnect(connection_object)

Usage (Generalised Workflow)

Step 1: Initialise Config File

We need to store your configuration details in a file somewhere on disk. You can choose where.

A common practice is to create a hidden file in your home directory.

We’ll create our config file: ~/.easydb

easydb_init(config_file = '~/.easydb')

This only needs to be done once.

Step 2: Connect to Database

Connect to databases:

easydb_connect('database_name', '~/.easydb')

Step 3: Disconnect when finished

Disconnect from databases:

easydb_disconnect(connection)

What to expect

The first time you try to connect to a database, you may have to answer some questions about the database (depending on the database type you’re connecting to).

Once you’ve setup the configuration, you will not have to re-enter host/port/creds unless you set the argument from_scratch = TRUE. This argument will delete the existing configuration and credentials for the given database and prompt you to supply updated information.

Miscellaneous Functionality

# List  previously configured databases
easydb_available_databases('~/.easydb')

How does easydb work?

Database configurations (host, port, driver, etc) are stored in a configuration file that will be created at a user-specified location (we recommend ~/.easydb).

Credentials are stored separately in your operating systems credential store. This is powered by keyring. If you’re on linux you may need to install the secret service library. See the readme for details.

Metadata

Version

1.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows