Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okunishinishi/node-mysqlspec
Generate JSON schema from mysql tables.
https://github.com/okunishinishi/node-mysqlspec
Last synced: 2 months ago
JSON representation
Generate JSON schema from mysql tables.
- Host: GitHub
- URL: https://github.com/okunishinishi/node-mysqlspec
- Owner: okunishinishi
- License: mit
- Created: 2015-08-11T00:57:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-23T00:10:35.000Z (over 7 years ago)
- Last Synced: 2024-11-03T19:21:28.604Z (2 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 11
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mysqlspec
==========[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
[![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url][bd_repo_url]: https://github.com/okunishinishi/node-mysqlspec
[bd_travis_url]: http://travis-ci.org/okunishinishi/node-mysqlspec
[bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-mysqlspec.svg?style=flat
[bd_license_url]: https://github.com/okunishinishi/node-mysqlspec/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-mysqlspec
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-mysqlspec.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-mysqlspec.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-mysqlspec
[bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-mysqlspec.svg
[bd_npm_url]: http://www.npmjs.org/package/mysqlspec
[bd_npm_shield_url]: http://img.shields.io/npm/v/mysqlspec.svg?style=flat
[bd_bower_badge_url]: https://img.shields.io/bower/v/mysqlspec.svg?style=flatGenerate JSON schema from mysql tables.
```bash
npm install mysqlspec --save-dev
```Describe database data.
```Javascript
var mysqlspec = require('mysqlspec');// Mysql connect config.
var config = {
user: 'root',
password: 'my_password',
host: 'localhost',
database: 'my_db'
};
// Get spec for connected database
mysqlspec(config, function (err, schema) {
console.log("schema=" + JSON.stringify(schema, null, 4));
});
```This will result like:
```Javascript
schema = { // Schemas for in "my_db" database.
'TEST_SHOP': { // Schema for in "my_db.TEST_SHOP" table.
name: 'my_db.TEST_SHOP',
properties: {
id: {type: 'integer', maxLength: 5},
article: {type: 'integer', maxLength: 4},
dealer: {type: 'string', maxLength: 20},
price: {type: 'number'}
},
required: ['id', 'article', 'dealer', 'price'],
additionalProperties: false
},
'TEST_PERSON':{
/**...*/
}
};
```| Signature | Description |
| --------- | ----------- |
| mysqlspec(config, callback) | Get JSON schem for tables in a database. |
| mysqlspec(config, databaseName, callback) | Get JSON schem for tables in a database. |
| mysqlspec(config, databaseName, tableName, callback) | Get JSON schem for a specific table. |### Connection Options
`mysqlspec` uses [node-mysql](https://github.com/felixge/node-mysql/) as connector.
For more advanced setting, see the [node-mysql documents about Connection options](https://github.com/felixge/node-mysql/#connection-options)License
-------
This software is released under the [MIT License](https://github.com/okunishinishi/node-mysqlspec/blob/master/LICENSE).Links
------+ [node-mysql](https://github.com/felixge/node-mysql/)
+ [node-mysqldesc](https://github.com/okunishinishi/node-mysqldesc)
+ [json-schema](http://json-schema.org/)