Convert Regularly-Formatted Text to Database Table Insert Scripts
Failed to load latest commit information.
css Initial import Sep 28, 2012
ddl_builder Removing redundant single-quote escape logic Mar 14, 2013
.gitignore Ignoring node_modules Jan 23, 2013
.travis.yml Travis-CI hooks Oct 3, 2012
index.html Initial import Sep 28, 2012
main.js Using nodejs instead of phantomjs for testing QUnit, for better date Jan 23, 2013
nodetest.js Using nodejs instead of phantomjs for testing QUnit, for better date Jan 23, 2013
package.json Fixing package definition Jan 23, 2013
qunit.html Typo in qunit header Jan 24, 2013
qunit_main.js Using nodejs instead of phantomjs for testing QUnit, for better date Jan 23, 2013
run-qunit.js Adding more detail to the output when the tests fail Oct 3, 2012
text.js Initial import Sep 28, 2012

DDL Builder

Build Status


This code uses JavaScript to parse plain text, tabular data and transform it into valid DDL and DML scripts, usable for immediate insertion into a database.

The plain text can be formatted in any number of different ways. The only assumptions are that the first row contains the header names, and that there is a consistent delimiter between each "cell". See ddl_builder/qunit/fixture.html for examples of the variety of formats supported.

The code will determine the proper column type based on the data provided, including field length (based on the longest value).

Right now, the database products supported are MySQL, Oracle, PostgreSQL, SQLite, and MS SQL Server (2008+).

This was originally developed as a utility for SQL Fiddle, to aid in the rapid construction of mock databases based on the text provided by people when they ask questions on sites like StackOverflow.

Running the example

I've provided an extremely simple plain HTML UI that makes uses of this library. If you download this project into any web-accessible folder and browse to /index.html, you will have the option to add input text and transform it into the expected DDL/DML.

This should provide sufficient clarity as to how the whole thing works. If you are a bit lost, I suggest looking at /main.js; this contains the dependency loading, instantiation, UI bindings and execution calls that are used to make the library do useful things. You'll need to do something quite similar to make it work in your project.

You can move around some of the paths of things fairly easily; you'll just need to make sure that wherever you move them, you update the paths in your main call to requirejs.config().

You can also run the QUnit tests by browsing to /qunit.html

Technologies used


Copyright Jake Feasel, 2012

Released under the terms of the MIT License.