Generate fake SQL data using JavaScript

2014-05-29 1 min read

    A problem I occasionally run into is needing to generate a bunch of fake data and insert it into a database table. My usual approach has been to generate this data in Excel and then use a series of string concatenations to generate the necessary insert statements which I’d then execute in the SQL client. After doing this one too many times I decided it was time for a better, more automated approach and hacked one together in JavaScript. It’s currently a part of my js-tools GitHub repo and suggestions are welcome. One thing I definitely need to add is the ability to specify the range of possible values for each field rather than using a hardcoded distribution.

    JS Tool to generate SQL insert statements