def forge(category, post, comment): """Generate fake data.""" from myblog.fakes import fake_admin, fake_categories, fake_posts, fake_comments db.drop_all() db.create_all() click.echo('正在创建管理员...') fake_admin() click.echo('正在创建 %d 个分类...' % category) fake_categories(category) click.echo('正在创建 %d 篇文章...' % post) fake_posts(post) click.echo('正在创建 %d 条评论...' % comment) fake_comments(comment) # click.echo('正在创建 %d 条二级评论...' % comment) # comments = Comment.query.all() # for comment in comments: # fake_sub_comments(comment) click.echo('已完成')
def initdb(drop): if drop: click.confirm('此操作将删除数据库,是否继续?', abort=True) db.drop_all() click.echo('删除表...') db.create_all() click.echo('初始化数据库...')
def forge(category, post, comment): """ 生成虚拟数据 :param category: :param post: :param comment: :return: """ from myblog.fakes import fake_admin, fake_categories, fake_posts, fake_comments, fake_links db.drop_all() db.create_all() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d categories...' % category) fake_categories(category) click.echo('Generating %d posts...' % post) fake_posts(post) click.echo('Generating %d comments...' % comment) fake_comments(comment) click.echo('Generating links...') fake_links() click.echo('Done.')
def forge(category, post, comment): """Generates the fake categories, posts, comments and links.""" from myblog.fakes import ( fake_admin, fake_categories, fake_posts, fake_comments, fake_links, ) db.drop_all() db.create_all() click.echo("Generating the administrator...") fake_admin() click.echo("Generating %d categories..." % category) fake_categories(category) click.echo("Generating %d posts..." % post) fake_posts(post) click.echo("Generating %d comments..." % comment) fake_comments(comment) click.echo("Generating links...") fake_links() click.echo("Done.")
def initdb(drop): """Initialize the database.""" if drop: click.confirm('This operation will delete the database, do you want to continue?', abort=True) db.drop_all() click.echo('Drop tables.') db.create_all() click.echo('Initialized database.')
def initdb(drop): if drop: click.confirm( 'This operation will delete the database, do you want to continue?', abort=True) db.drop_all() click.echo("数据库已清空") db.create_all() click.echo("数据库初始化完成")
def initdb(drop): if drop: click.confirm( "this operation will delete the database,do you want to continue?", abort=True) db.drop_all() click.echo('Drop tables') db.create_all() click.echo('Initilize database')
def initdb(drop): """Initialize the database.""" if drop: click.confirm('此操作将会删除数据库,确认?', abort=True) click.echo('正在删除所有数据表') db.drop_all() click.echo('已删除所有数据表') click.echo('正在初始化数据库') db.create_all() click.echo('已初始化数据库')
def forge(category, post, comment): '''Generates the fake categories, posts and comments.''' db.drop_all() db.create_all() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d categories' % category) fake_categories(category) click.echo('Generating %d posts' % post) fake_posts(post) click.echo('Generating %d comments' % comment) fake_comments(comment) click.echo('done.')
def forge(category, post, comment): from myblog.fakes import fake_admin, fake_categories, fake_comments, fake_posts db.drop_all() db.create_all() click.echo("生成管理员") fake_admin() click.echo("生成分类") fake_categories() click.echo("生成博文") fake_posts(post) click.echo("生成评论") fake_comments(comment) click.echo("生成完成")
def forge(category, post, comment): """Generate fake data.""" from myblog.fakes import fake_admin, fake_categories, fake_posts, fake_comments db.drop_all() db.create_all() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d categories...' % category) fake_categories(category) click.echo('Generating %d posts...' % post) fake_posts(post) click.echo('Generating %d comments...' % comment) fake_comments(comment) click.echo('Done.')
def initdb(drop): """Initialize the database.""" if drop: click.confirm( 'This operation will delete the database, do you want to continue', abort=True) db.drop_all() click.echo('Drop tables') db.create_all() click.echo('Creating the categorys...') Math = Category(name="Math") Computer = Category(name="CS") Physics = Category(name="Physics") Life = Category(name="Life") db.session.add_all([Math, Computer, Physics, Life]) db.session.commit() click.echo('Initialized databases.')
def forge(category, post, comment): from myblog.fakes import fake_posts, fake_comments, fake_categories, fake_admin, fake_links db.drop_all() db.create_all() click.echo('Generating the administrator...') fake_admin() click.echo("Generating %d categories..." % category) fake_categories(category) click.echo("Generating %d posts" % post) fake_posts(post) click.echo('Generating %d comments' % comment) fake_comments(comment) click.echo("Generating links") fake_links() click.echo("ok")
def forge(category, post, comment): from myblog.fakes import fake_admin, faker_categoryies, fake_posts, fake_comments, fake_links db.drop_all() db.create_all() click.echo('Generating the administrator...') fake_admin() click.echo('Generating {} categories...'.format(category)) faker_categoryies(category) click.echo('Generating %d posts...' % post) fake_posts(post) click.echo('Generating %d comments...' % comment) fake_comments(comment) click.echo('Generating links...') fake_links() click.echo('Done.')
def forge(category, post, comment): """生成虚假数据。""" from myblog.fakes import fake_admin, fake_categories, fake_posts, fake_comments, fake_links db.drop_all() db.create_all() click.echo('生成管理员...') fake_admin() click.echo('生成 %d 个分类...' % category) fake_categories(category) # 这里的category代表数量,下同 click.echo('生成 %d 篇文章...' % post) fake_posts(post) click.echo('生成 %d 条评论...' % comment) fake_comments(comment) click.echo('生成分享链接...') fake_links() click.echo('完成')
def tearDown(self): db.drop_all() self.context.pop()
def setUp(self): super(CLITestCase, self).setUp() db.drop_all()