def initdb(drop): if drop: click.confirm('continue dropping ?', abort=True) db.drop_all() click.echo('drop done ..') db.create_all() click.echo('Initlize Database ..')
def initdb(drop): if drop: click.confirm('This operaton 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("此选项将会删除所有数据,确定吗?", abort=True) db.drop_all() click.echo("Drop tables") db.create_all() click.echo("initialized database..")
def setUp(self): app.config.update(TESTING=True, WTF_CSRF_ENABLED=False, SQLALCHEMY_DATABASE_URI='sqlite:///:memory:') db.create_all() self.client = app.test_client() self.runner = app.test_cli_runner()
def setUpClass(cls): app.config.update(TESTING=True, WTF_CSRF_ENABLED=False, SQLALCHEMY_DATABASE_URI='sqlite:///:memory:') db.create_all() print('setUpClass') cls.client = app.test_client() cls.runner = app.test_cli_runner()
def initdb(drop): """Initialize the database.""" if drop: click.confirm('此操作将删除数据库,是否要继续?', abort=True) db.drop_all() click.echo('删除表.') db.create_all() click.echo('初始化数据库.')
def initdb(drop): """初始化数据库""" if drop: click.confirm('此操作会删除数据库,是否确定继续', abort=True) db.drop_all() click.echo('删除表完成') db.create_all() click.echo('初始化数据库完成')
def init_db(drop): if drop: db.drop_all() click.confirm('Do you want drop all tables', abort=True) click.echo('Drop all table') db.create_all() click.echo('Init all tables') pass
def init_db(drop): """Initialize the database.""" if drop: click.confirm('Do you want to delete the database?', abort=True) db.drop_all() click.echo('Drop tables.') db.create_all() click.echo('Initialized database.')
def init_db(drop): """initialize database.""" if drop: click.confirm('All data well be delete, do you want to continue?', abort=True) db.drop_all() click.echo('drop all database.') db.create_all() click.echo('database initialized')
def initdb(drop): if drop: click.confirm( 'the operation will delete database,do u want to continue?', abort=True) db.drop_all() click.echo('drop tables') db.create_all() click.echo('initialized database')
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 init_db(): choice = input( "This operation will delete the database, do you want to continue? y/n\n" ) if choice in ["yes", "y"]: db.drop_all() print("Drop tables.") db.create_all() print("Initialized database.") elif choic in ["no", "n"]: print("OK! Byebye!") else: print("Wrong choice! Please reoperate!")
def forge(count): from faker import Faker db.drop_all() db.create_all() fake = Faker() click.echo('working...') for i in range(count): message = Message(name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_year()) db.session.add(message) db.session.commit() click.echo('created %d messages' % count)
def index(): db.create_all() form = HelloForm() if form.validate_on_submit(): name = form.name.data body = form.body.data message = Message(body=body, name=name) db.session.add(message) db.session.commit() flash('Your Message have been sent to the word!') return redirect(url_for('index')) messages = Message.query.order_by(desc(Message.timestamp)).all() return render_template('index.html', form=form, messages=messages)
def forge(count): """Gernerate fake messages!""" from faker import Faker db.drop_all() db.create_all() fake = Faker('zh_CN') click.echo('Working......') for i in range(count): message = Message(name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_year()) db.session.add(message) db.session.commit() click.echo('Created %d fake messages!' % count)
def forge(count): '''Generate fake messages''' from faker import Faker db.drop_all() db.create_all() # fake = Faker('zh_cn') # 控制生成中文数据 fake = Faker() click.echo('now faker is Working ....') for i in range(count): message = Message(name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_month()) db.session.add(message) db.session.commit() click.echo(f' {count} messages was created.')
def forge(count): from faker import Faker db.drop_all() db.create_all() ### Faker()默认为英文,Faker('zh-CN')为中文 fake = Faker('zh-CN') click.echo('Working...') for i in range(count): message = Message(name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_year()) db.session.add(message) db.session.commit() click.echo('Created %d fake messages. ' % count)
def forge(count): '''Generate fake messages''' from faker import Faker db.drop_all() db.create_all() fake = Faker() click.echo('Working...') for i in range(count): message = Message( name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_year() ) db.session.add(message) db.session.commit() click.echo('Created {} fake messages.'.format(count))
def forge(count): """Generate fake messages.""" db.drop_all() db.create_all() fake = Faker() click.echo("Working...") for i in range(count): message = Message(name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_year()) db.session.add(message) db.session.commit() click.echo("Created %d fake messages." % count)
def generate_messages(count): """Generate fake messages.""" from faker import Faker db.drop_all() db.create_all() fake = Faker() for i in range(count): message = Message(name=fake.name(), content=fake.sentence(), timestamp=fake.date_time_this_year() ) db.session.add(message) db.session.commit() click.echo('Fake messages have been generated.')
def generate(count): from faker import Faker db.drop_all() db.create_all() fake = Faker() print("Working...") for i in range(count): message = Message(name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_year()) db.session.add(message) db.session.commit() print("Created %d fake messages." % count)
def admin(username, password): """Create user.""" db.create_all() user = User.query.first() if user is not None: click.echo('Updating user...') user.username = username user.set_password(password) # 设置密码 else: click.echo('Creating user...') user = User(username=username, name='Admin') user.set_password(password) # 设置密码 db.session.add(user) db.session.commit() # 提交数据库会话 click.echo('Done.')
def forge(count): db.drop_all() db.create_all() from faker import Faker fake = Faker('en') click.echo("Working....") for i in range(count): message = Message( name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_year(), ) db.session.add(message) db.session.commit() click.echo(f"Create {count} fake messages.")
def forge(count): """Generate fake messages.""" from faker import Faker db.drop_all() db.create_all() fake = Faker() click.echo('Working...') for i in range(count): message = Message(name=fake.name(), s_date=fake.date_time_this_month(), e_date=fake.date_time_this_month(), timestamp=fake.date_time_this_year()) db.session.add(message) db.session.commit() click.echo('Created %d fake messages.' % count)
def forge(count): """生成虚拟数据""" from faker import Faker db.drop_all() db.create_all() # 默认虚拟数据语言为英文,可以传入第一个参数locale进行定制,简体中文为zh_CN,繁体中文为zh_TW fake = Faker() click.echo('Working...') for i in range(count): message = Message(name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_year()) db.session.add(message) db.session.commit() click.echo(f'Created {count} fake message.')
def forge(count): """Generate fake messages.""" from faker import Faker from faker.providers.date_time import datetime_to_timestamp db.drop_all() db.create_all() fake = Faker('zh_CN') click.echo('Working...') for i in range(count): message = Message( name=fake.name(), body=fake.sentence(), timestamp=fake.date_time_this_month() ) db.session.add(message) db.session.commit() click.echo('Created %d fake messages.' % count)
def refresh(): global answer_feedback db.drop_all() db.create_all() print("Deleted comments Database") # Clear Named entity # Clear caches: utils.commonDB.comments = {'PER': [], 'LOC': [], 'ORG': []} with open(nen_url, mode='w') as file: file.write("") print("Deleted named entity!") # Delete inference result with open(inf_res_url, mode='w') as file: file.write("") answer_feedback = [] print("Inference Result deleted!") return redirect(url_for("index"))
def forge(count): """Generate fake messages.""" from faker import Faker db.drop_all() db.create_all() print("Dropped!") fake = Faker() click.echo('Working...') for i in range(count): message = Message( # name=fake.name(), body="None", c_type="None", nl_body="None", timestamp=fake.date_time_this_year()) print(message) db.session.add(message) db.session.commit() click.echo('Created %d fake messages.' % count)
def forge(count): '''Generate fake messages.''' from faker import Faker db.drop_all() db.create_all() fake = Faker('zh_CN') click.echo('Working...') my_word_list = [ '何日请缨提锐旅,一鞭直渡清河洛。', '杜鹃再拜忧天泪,精卫无穷填海心。', '半亩方塘一鉴开,天光云影共徘徊。', '大漠风尘日色昏,红旗半卷出辕门。', '金鞍玉勒寻芳客,未信我庐别有春。', '不知天上宫阙,今夕是何年。', '十年一觉扬州梦,赢得青楼薄幸名。', '一年春又尽,倚杖对斜晖。', '欲系青春,少住春还去。', '桃李务青春,谁能贯白日。' ] for i in range(count): message = Message(name=fake.name(), body=fake.sentence(ext_word_list=my_word_list), timestamp=fake.date_time_this_year()) db.session.add(message) db.session.commit() click.echo('Create %d fake messages' % count)