Tag Archives: PostgreSQL

Incorporating SQL in Stata code

Here is a snippet of code showing how one can include SQL in Stata code (I assume that the ODBC connection has been set up). #delimit ; local sql ” SELECT * FROM director_bio.directorship_results WHERE non_match AND start_date < date_filed … Continue reading

Posted in PostgreSQL, Stata, Uncategorized | Tagged , , | Leave a comment

Prototyping PL/Python functions

I’ve seen a variable called numerical intensity crop up in a couple of papers recently (one example is Lundholm, Rogo, and Zhang (2014)). I spent a little time coming up with a Python program to extract numbers from text. Once … Continue reading

Posted in PostgreSQL, Python | Tagged , , , , | Leave a comment

Upgrading PostgreSQL from 9.4 beta1 to 9.4 beta2

MacPorts installs PostgreSQL 9.4 beta2 in the same directory as PostgreSQL 9.4 beta 1 was in. And going from beta 1 to beta 2 requires an upgrade for the cluster to work. So upgrading is more like going from 9.3 … Continue reading

Posted in Mac, PostgreSQL | Tagged , , | Leave a comment

Get “tone” from corporate disclosures: PostgreSQL, Python, and R.

The paper by Loughran and McDonald (2011) develops lists of words that are intended to reflect “tone” in financial text. The following code retrieves these lists and applies them to a large body of text (over a billion words) from … Continue reading

Posted in Uncategorized | Tagged , , , , , , , | 4 Comments

Using JSON to pass dictionaries from Python to PostgreSQL and back

To my (very untrained) eyes, JSON looks like Python dictionaries. I’d wondered if one could use JSON to pass around Python dictionaries. Turns out that it works quite well. Task Get the top N words from passages of text (conference … Continue reading

Posted in PostgreSQL, Python | Tagged , , , , | 1 Comment

RPostgreSQL (R) versus psycopg (Python)

Here’s a rather simplistic comparison of the performance of R and Python in getting data from PostgreSQL. R: Time taken: 26-27 seconds. Python: Time taken: Around 6 seconds. I’m impressed. I’ve never really been bothered by performance in getting data … Continue reading

Posted in PostgreSQL, R | Tagged , , | Leave a comment

Using PL/R for quantiles

I was trying to reproduce a plot from a book today. The plot has quantiles (10th, 25th, 50th, 75th, and 90th percentiles) for market-to-book for US companies from 1963 through 2010. I wanted to pull the data together in PostgreSQL, … Continue reading

Posted in PostgreSQL | Tagged | Leave a comment