WRDS is a leading provider of research data to academics and other researchers in business and related fields. WRDS provides a PostgreSQL database, but this is a read-only database.
For some tasks, the inability to write data to the database is very constraining. For example, if I want to run an event study using daily stock returns, I will need to merge my (relatively small) local data set events with crsp.dsf, which is about 18GB of data.
One option is to maintain my own database with a copy of crsp.dsf and write events to that database and merge there. But I am looking for an option that allows me to use the WRDS database for this purpose. Unfortunately, there is no way to use copy_to or dbWriteTable, as the WRDS database is read-only.
A more up-to-date answer than the one below is to use the
copy_inlinefunction from thedbplyrpackage, which was added following an issue filed on this topic.One option is to use something like the following function, which turns a local data frame into a remote data frame using SQL even when using a read-only connection.
Here is an illustration of the function in use. Function has been tested on PostgreSQL and SQL Server, but will not work on SQLite (due to lack of
VALUESkeyword that works in this way). I believe it should work on MySQL or Oracle, as these have theVALUESkeyword.Created on 2021-04-01 by the reprex package (v1.0.0)