Skip to content

convert django model's verbose_name to a modified sql

License

Notifications You must be signed in to change notification settings

RunningFaster/DjangoColumnComment

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-column-comment

convert django model's verbose_name to a modified sql

Example

you have a table named book as below

class Book(Model):
    ISBN = CharField(max_length=32, null=False, default="", db_column="ISBN", verbose_name=r"book ISBN")
    name = CharField(max_length=32, null=True, db_column="name", verbose_name=r"book name")
    price = FloatField(null=False, default=0, db_column="price", verbose_name=r"book price")
    create_time = DateTimeField(auto_now_add=True, db_column="create_time", verbose_name=r"book created time")

    _db = "black_book_shop"

    class Meta:
        db_table = "book"

it will dumps serveral lines of sql as below

ALTER TABLE `black_book_shop`.`book` MODIFY `id` int NOT NULL COMMENT 'ID';
ALTER TABLE `black_book_shop`.`book` MODIFY `ISBN` varchar(32) NOT NULL COMMENT 'book ISBN';
ALTER TABLE `black_book_shop`.`book` MODIFY `name` varchar(32) DEFAULT NULL COMMENT 'book name';
ALTER TABLE `black_book_shop`.`book` MODIFY `price` double NOT NULL COMMENT 'book price';
ALTER TABLE `black_book_shop`.`book` MODIFY `create_time` datetime NOT NULL COMMENT 'book created time'

Installation

git clone git@github.com:Altynai/django-column-comment.git --depth=1
cd django-column-comment
python setup.py install

Usage

Usage: dcc.py [options] path

  path                  django project's path

Options:
  -h, --help            show this help message and exit
  -r, --recursion       serach for the possible django projects hierarchically
  -o OUTPUT, --output=OUTPUT
                        save the the result sql file to the path [default: .]
  -n NAME, --name=NAME  save result to the named file [default: models-comment.sql]

About

convert django model's verbose_name to a modified sql

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published