orm-creator

Automatically maps sql tables and generates classes for ORM manipulation


Keywords
sqlalchemy, automate, ORM, MySql
License
MIT
Install
pip install orm-creator==1.0.0

Documentation

ORM - Creator

Description

Map SQL (MySQl) table(s) and generate ORM classes for them automatically !!
This proves to be very useful especially in cases where the number of tables is huge

Demo

From command line

cli_demo

As a python module

module_demo

Installation

Using this repository
git clone http://github.com/shravan97/ORM-Creator
cd ORM-Creator
python setup.py install
Using pip

Coming up soon !

Usage

usage: orm-creator [-h] [-db DB] [-t TABLES [TABLES ...]] [-host HOST]
                   [-u UNAME] [-o OUTFILE]

optional arguments:
  -h, --help            show this help message and exit
  -db DB                The name of database from which tables will have to
                        mapped
  -t TABLES [TABLES ...]
                        List of table names each separated by one or more
                        space
  -host HOST            Name of the MySql host For Eg., localhost ,
                        mysql.mydomain.com ,....etc
  -u UNAME              Your Mysql username
  -o OUTFILE            Output file name ,along with its extension and
                        absolute path For Eg. , /home/shravan97/Desktop/out.py  

Sample

As a command line app
orm-creator -u root -db demo -t users migrations -o /var/www/flaskApp/db.py

# The above statement maps `users` and `migrations` tables  
As a module
from orm_creator import ormCreator
oc = ormCreator(config,'demo',['users','migrations'],'/var/www/flaskApp/db.py')

# config is stored as a dict . For eg. , config = {'uname':'root','password':'**','host':'localhost'}

oc.generate_file()

Please check here for demo files

Contributions

Found any cool idea that could be implemented here ? Go ahead and give a pull request 😄 !
You may as well put it up as an issue here

Contributors

License

GNU General Public License v3 (GPLv3)

gpl