{"id":14066952,"url":"https://github.com/nicholas-alonzo/sqlBatchInsertR","last_synced_at":"2025-07-30T00:31:56.618Z","repository":{"id":162706652,"uuid":"369715538","full_name":"nicholas-alonzo/sqlBatchInsertR","owner":"nicholas-alonzo","description":"SQL DML Support for RODBC","archived":false,"fork":false,"pushed_at":"2021-06-15T06:10:06.000Z","size":95,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-13T07:12:00.537Z","etag":null,"topics":["database","r","rodbc","sql","sql-server","sqlserver"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicholas-alonzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-05-22T04:38:31.000Z","updated_at":"2022-08-11T00:20:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"6ab249a9-bc8f-4d40-9b3f-b86155cfca6e","html_url":"https://github.com/nicholas-alonzo/sqlBatchInsertR","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholas-alonzo%2FsqlBatchInsertR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholas-alonzo%2FsqlBatchInsertR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholas-alonzo%2FsqlBatchInsertR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholas-alonzo%2FsqlBatchInsertR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicholas-alonzo","download_url":"https://codeload.github.com/nicholas-alonzo/sqlBatchInsertR/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228065148,"owners_count":17863947,"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","r","rodbc","sql","sql-server","sqlserver"],"created_at":"2024-08-13T07:05:20.976Z","updated_at":"2024-12-04T07:30:32.480Z","avatar_url":"https://github.com/nicholas-alonzo.png","language":"R","readme":"# sqlBatchInsertR\n\n`sqlBatchInsertR` provides an efficient way of inserting a data frame into a database table and handling SQL DML statements. It is built on top of the `RODBC `package and aims to extend its functionality.\n\n__This has *currently* been tested for use with Microsoft SQL Server and is in development.__\n\n## Inspiration and Motivation\n\nIn the summer of 2016 I volunteered at a non-profit community health clinic not knowing it would be the start to a full-time career. My first big project was to compare monthly Excel records to records in a Microsoft SQL Server database. To accomplish the task, I used R and the `RODBC` package. \n\nThe next phase was to track the Excel records in more detail. This involved data modeling and designing an ETL process. One of the challenges at this point was the data frame to database writing time. `RODBC` offers `sqlSave()`, but it couldn't keep up with the demand. I wasn't the only one that noticed; others raised this issue on Stack Overflow, but no coded solution was proposed.\n\nThis is when I had the inspiration to write my own functions. I started writing the code in 2017 until I reached a solution of creating batches of parameterized INSERT statements. It was a *__major__* speed up and I became reliant on it for other projects. The code lived in a few scripts until I started building it out as an internal package in 2018.\n\nIt's now 2021 and I've decided to open source the package in hopes it'll be useful to others. What's nice about it is that it's minimal. Only base R is used for data manipulation and `RODBC` for database connectivity.\n \n## Prerequisites\n\n- [R](https://cloud.r-project.org/) (\u003e= 4.0.0)\n- [RODBC](https://cran.r-project.org/web/packages/RODBC/) (\u003e= 1.3.0)\n\n## Installation\n\n1. Install `RODBC` if necessary. In R, copy the following code into the console and press __Enter__.\n\n\t```r\n\tinstall.packages(\"RODBC\")\n\t```\n\n### In Release: Using Source Package\n\n1. Download the source package (tar.gz) of the current release [here](https://github.com/nicholas-alonzo/sqlBatchInsertR/releases).\n\n2. In R, copy the following code into the console. \n\n\t```r\n\tinstall.packages(\"sqlBatchInsertR_#.tar.gz\", repos = NULL, type = \"source\")\n\t```\n3. Change the first argument to be the path of the downloaded (tar.gz) file and press __Enter__.\n\n### In Development: Using `devtools` \n\nThe R package `devtools` allows users to install packages directly from GitHub. In R, copy the following code into the console and press __Enter__.\n\n```r\n# install devtools if necessary\ninstall.packages(\"devtools\")\n\n# install sqlBatchInsertR and dependent package from the GitHub repository\ndevtools::install_github(\"nicholas-alonzo/sqlBatchInsertR\")\n```\n\n### In Development: Using Command Line\n\n1. Install [Git](http://git-scm.com/downloads) if necessary.\n\n2. Open a terminal.\n\n3. Change the current working directory to the location where you want the cloned directory.\n\n4. Copy the following command into terminal and press __Enter__. This will make a full copy of the repository data that GitHub has at that point in time, including all versions of every file and folder for the project.\n \n\t```\n\tgit clone https://github.com/nicholas-alonzo/sqlBatchInsertR\n\t```\n\n5. Copy the following command into terminal and press __Enter__. This will install the source package to your current version of R.\n \n\t```\n\tR CMD INSTALL sqlBatchInsertR\n\t```\n\n## Usage and Features\n\n__This has *currently* been tested for use with Microsoft SQL Server and is in development.__\n\nBelow are the main functions of the package. \n\n```r\nsqlBatchInsert(dbconn, df, dbtable, nrecords = 1000)\n```\n- Inserts a data frame into a database table in a transaction using a list of parameterized INSERT statements.\n\n```r\nsqlTransaction(dbconn, statement, prompt = TRUE, addl_text = NULL)\n```\n- Prompts the user to commit or rollback the results of a SQL INSERT, UPDATE, or DELETE statement.\n\n```r\nsqlRowsAffected()\n```\n- Returns the number of rows affected in a database table when ```sqlBatchInsert()``` or ```sqlTransaction()``` are successfully executed.\n\n```r\nsqlOdbcErrors()\n```\n- Returns a list of ODBC errors after ```sqlBatchInsert()``` or ```sqlTransaction()``` fails to execute.\n\n## Documentation\n\nPlease refer to the\n[Wiki](https://github.com/nicholas-alonzo/sqlBatchInsertR/wiki) for additional documentation including use cases, benchmarks, and limitations.\n\n## Contributing\n\n- 🦾 Share ideas for feature enhancements [here](https://github.com/nicholas-alonzo/sqlBatchInsertR/discussions/categories/enhancements). \n- ‼️ Raise issues regarding functionality and share solutions [here](https://github.com/nicholas-alonzo/sqlBatchInsertR/discussions/categories/issues).\n- 📓 Chat about anything and everything [here](https://github.com/nicholas-alonzo/sqlBatchInsertR/discussions/categories/general).\n- ✋ Ask for help and share solutions [here](https://github.com/nicholas-alonzo/sqlBatchInsertR/discussions/categories/help).\n- 💌 Share with me if this package is helpful [here](https://github.com/nicholas-alonzo/sqlBatchInsertR/discussions/categories/kind-words).\n\n## License\nsqlBatchInsertR is released under the [GNU General Public License v2.0](https://github.com/nicholas-alonzo/sqlBatchInsertR/blob/main/LICENSE).\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholas-alonzo%2FsqlBatchInsertR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicholas-alonzo%2FsqlBatchInsertR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholas-alonzo%2FsqlBatchInsertR/lists"}