def db(app, request):
    def teardown():
        db_.drop_all()

    db_.app = app
    db_.create_all()
    request.addfinalizer(teardown)
    return db_
Esempio n. 2
0
def test_db():
    db.create_all()
    all = TestCase.query.all()
    print(all)
    testcase = TestCase(name="1", steps='1,2,3')
    db.session.add(testcase)
    db.session.commit()
    all = TestCase.query.all()
    print(all)
Esempio n. 3
0
def recreate_db():
    db.drop_all()
    db.create_all()
    db.session.commit()
Esempio n. 4
0
def create_db():
    """Creates the db tables."""
    db.create_all()
Esempio n. 5
0
@desc:
"""
import datetime

from backend.server import db


class Task(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    # 人物执行的相关数据信息
    remark = db.Column(db.String(120))
    report = db.Column(db.String(120))
    # 指定时间格式,默认值为当前时间
    create_at = db.Column(db.DateTime, default=datetime.datetime.now)

    def as_dict(self):
        """
        返回一个标准的Python结构体
        :return:
        """
        return {'id': self.id,
                'remark': self.remark,
                'report': self.report,
                # 强转为字符串的格式
                'create_at': str(self.create_at)
                }


if __name__ == '__main__':
    db.create_all()
Esempio n. 6
0
def test_db_init():
    db.create_all()