brianc/node-sql — pull request #71 by tmont (2013-05-19 07:07:38+00:00)
Title: Command line generation tool

I wrote a CLI tool for automatically generating SQL definitions from a MySQL or PostgreSQL database. I updated the README with some basic instructions.

### Usage

$ node-sql-generate --dialect mysql --dsn "mysql://user:password@server/mydb" --schema mydb

Which will generate something akin to:

```javascript
// autogenerated by node-sql-generate v0.0.1 on Sun May 19 2013 00:01:46 GMT-0700 (PDT)
var sql = require('sql');

/**
* SQL definition for mydb.foo
*/
exports.foo = sql.define({
name: 'foo',
columns: [
'id',
'name'
]
});

/**
* SQL definition for mydb.bar
*/
exports.bar = sql.define({
name: 'bar',
columns: [
'id',
'foo_id',
'created'
]
});
```

### Dependencies
The CLI tool depends on either the `mysql` library or the `pg` library, which I make the user install themselves. The other alternative was to add another dependency for each of the libraries, which I figured would be overkill (since the CLI tool is more an optional convenience than a requirement). `npm` doesn't really have a way to specify a *truly* optional dependency, i.e. a dependency that a user could install iff they wanted to.

Currently, if the needed library isn't installed, it'll spit out a message telling the user to install it.

### Naming convention
The name of the binary is `node-sql-generate`, since using the default `sql` seemed a little too generic, and could possibly have conflicts. I don't really have a strong opinion, if you want to change it.