Code Monkey home page Code Monkey logo

jane's Introduction

jane

Introduction

Jane is an extensible code generator which allows you to generate SQL queries to create, drop and populate your database based on its data description. You describe these data in XML and Jane will then generate SQL queries for you, for the desired RDBMS (can be anything as long as there's a generator for it).

In short, it allows you to turn this:

<entity name="Product" plural="Products">
  <attributes>
    <attribute name="id" type="Integer" primary-key="true" />
    <attribute name="name" type="String" max-length="63" />
    <attribute name="price" type="Decimal(5,2)" />
    <attribute name="description" type="String" max-length="1023" />
    <attribute name="stock" type="Integer" />
  </attributes>
  <references>
    <reference entity="ProductCategory" attribute="id" as="category" />
  </references>
</entity>

into this (for MySQL) :

CREATE DATABASE IF NOT EXISTS MyDatabaseName;
USE MyDatabaseName;

CREATE TABLE Products (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(63) NOT NULL,
  price DECIMAL(5,2) NOT NULL,
  description VARCHAR(1023) NOT NULL,
  stock INT NOT NULL,
  category INT NOT NULL,

  FOREIGN KEY (category) REFERENCES ProductsCategories (id)
);

or this (for SQLite) :

CREATE TABLE Products (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name VARCHAR NOT NULL,
  price DECIMAL(5,2) NOT NULL,
  description VARCHAR NOT NULL,
  stock INTEGER NOT NULL,
  category INTEGER NOT NULL,

  FOREIGN KEY (category) REFERENCES ProductsCategories (id)
);

Jane is RDBMS and programming language agnostic. You can use one of the generators supported by default or write your own generator to generate isolated model classes for a specific programming language, whole APIs or to add support for another RDBMS, everything based only on your data description.

Jane is an object-oriented method and only requires to know the basics of programming (including XML or HTML) to be used. However if you want to write your own generator or to modify an existing one, JavaScript (ES6) knowledge is required.

Installation

Coming soon to NPM. In the meantime just clone the repo locally :

git clone https://github.com/flawyte/jane.git
cd jane

Usage

node index.js <generator-name> --from <XML file/directory> [<generator-specific arguments>]
  • generator-name : See the list of supported generators above or add your own.
  • from : Relative path to a Jane-compliant XML source file or to a whole directory (each XML file it contains will be processed). See the XML files in one of the tests/example*/ directories
  • generator-specific arguments : Type node index.js <generator-name> --help for a list of additional arguments supported by a generator if any

For example, if you want to generate the SQL code to create, drop and insert some data, say 5 rows in each table, into the SQLite database corresponding to tests/example1/ :

node index.js sqlite --from tests/example1/ --create --drop --insert-into=5

And see the output files in tests/example1/generated/sqlite/.

Supported generators

Currently supported generators by default :

  • MySQL
  • PostgreSQL
  • SQLite
  • JS/ES6 (work in progress, very basic support)

jane's People

Contributors

hormesiel avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.