{"id":14067134,"url":"https://github.com/Aypak/dbhelpers","last_synced_at":"2025-07-30T00:32:30.955Z","repository":{"id":80169101,"uuid":"275116248","full_name":"Aypak/dbhelpers","owner":"Aypak","description":"Helper Functions for Common Database Operations in R","archived":false,"fork":false,"pushed_at":"2024-03-19T11:30:24.000Z","size":150,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-13T07:12:55.847Z","etag":null,"topics":["database","pool-connection","postgresql","r-package","schema"],"latest_commit_sha":null,"homepage":"https://aypak.github.io/dbhelpers/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aypak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-26T09:11:25.000Z","updated_at":"2022-02-28T11:45:32.000Z","dependencies_parsed_at":"2024-08-13T07:22:03.066Z","dependency_job_id":null,"html_url":"https://github.com/Aypak/dbhelpers","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aypak%2Fdbhelpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aypak%2Fdbhelpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aypak%2Fdbhelpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aypak%2Fdbhelpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aypak","download_url":"https://codeload.github.com/Aypak/dbhelpers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228065211,"owners_count":17863964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","pool-connection","postgresql","r-package","schema"],"created_at":"2024-08-13T07:05:26.946Z","updated_at":"2024-12-04T07:30:43.412Z","avatar_url":"https://github.com/Aypak.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# dbhelpers\n\n\u003e Helper functions to make working with databases a bit smoother\n\n\u003c!-- badges: start --\u003e\n[![R build status](https://github.com/Aypak/dbhelpers/workflows/R-CMD-check/badge.svg)](https://github.com/Aypak/dbhelpers/actions)\n\u003c!-- badges: end --\u003e\n\n## Overview\n\nThis package provides some functions to help work with (mostly PostgreSQL) databases, and to help clean your data.\n(This package has not yet been listed on CRAN)\n\nInstallation :\n```r\n# Download latest release zip file\ninstall.packages(\"\u003crelease zip file\u003e\",repos = NULL)\n\n# From Github\n# install.packages(\"devtools\")\ndevtools::install_github(\"Aypak/dbhelpers\")\n```\n\n## Functions available :\n- [connect_to_pg](#connect_to_pg)\n- [read_files_into_df](#read_files_into_df)\n- [create_lazy_conn](#create_lazy_conn)\n- [lazy_conn_all_tables](#lazy_conn_all_tables)\n- [get_first_name](#get_first_name)\n- [get_last_name](#get_last_name)\n\n\n#### read_files_into_df\nRead multiple files from a directory into a single dataframe. Essentially binding the contents of the files and filling missing columns with NA.\ne.g\n```r\nraw_data \u003c- read_files_into_df(file_directory=\"raw_csv_files\",file_pattern=\"*.csv\")\n```\n\n#### create_lazy_conn\nCreate a connection to a database table using a database pool object. The connection is exactly like a pool connection. It does not retreive any data until it is explicitly called. \n\n##### Example: \nAssume there is a [pool connection](https://db.rstudio.com/pool) to a PostgreSQL database called books_conn in the workspace.  \nIn the public schema, the database contains the tables:  \nusers,books,transactions\n\n```r\n# If we want to create a connection to the users table\nusers \u003c- create_lazy_conn(books_conn, schemaname = \"public\", \"users\")\n```\n\n#### lazy_conn_all_tables\nCreate connections the same as the [create_lazy_conn](#create_lazy_conn) function for all tables in a specified schema. The connections will have the same names as the tables they are connected to. \n\nFollowing the example above:\n```r\n# create connections to all tables in the public schema in the global environment\nlazy_conn_all_tables(books_conn,schemaname = \"public\", prefix = \"\", env = globalenv())\n\n# This will create the connection objects: users, books, transactions\n```\n\n#### get_first_name\nGet the first name from a full name separated by spaces \ne.g\n```r\nget_first_name(\"John Banda\")\n# [1] \"John\"\n```\n\n#### get_last_name\nGet the last name from a full name separated by spaces. If there are middle names, all of the middle names and last name will be taken as the last name. \ne.g\n```r\nget_last_name(\"John Bewzani Banda\")\n# [1] \"Bewzani Banda\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAypak%2Fdbhelpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAypak%2Fdbhelpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAypak%2Fdbhelpers/lists"}