示例#1
0
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 ..')
示例#2
0
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.')
示例#3
0
def initdb(drop):
    if drop:
        click.confirm("此选项将会删除所有数据,确定吗?", abort=True)
        db.drop_all()
        click.echo("Drop tables")
    db.create_all()
    click.echo("initialized database..")
示例#4
0
 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()
示例#5
0
 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()
示例#6
0
def initdb(drop):
    """Initialize the database."""
    if drop:
        click.confirm('此操作将删除数据库,是否要继续?', abort=True)
        db.drop_all()
        click.echo('删除表.')
    db.create_all()
    click.echo('初始化数据库.')
示例#7
0
def initdb(drop):
    """初始化数据库"""
    if drop:
        click.confirm('此操作会删除数据库,是否确定继续', abort=True)
        db.drop_all()
        click.echo('删除表完成')
    db.create_all()
    click.echo('初始化数据库完成')
示例#8
0
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
示例#9
0
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.')
示例#10
0
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')
示例#11
0
文件: commands.py 项目: iiFeng/notes
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')
示例#12
0
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.")
示例#13
0
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!")
示例#14
0
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)
示例#15
0
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)
示例#16
0
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)
示例#17
0
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.')
示例#18
0
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)
示例#19
0
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))
示例#20
0
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)
示例#21
0
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.')
示例#22
0
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)
示例#23
0
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.')
示例#24
0
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.")
示例#25
0
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)
示例#26
0
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.')
示例#27
0
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)
示例#28
0
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"))
示例#29
0
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)
示例#30
0
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)