Esempio n. 1
0
class Transaction(object):
    def __init__(self):
        self.db = BenchDB()
        self.db.delete_db()
        self.base_sql = "insert into student (id, name, age) values (%d, '%s', %d)"
        self.id = 0

    def run(self):
        self.id += 1
        sid = self.id
        base_sql = self.base_sql

        name = 'name%d' % sid
        age = random.uniform(6, 60)
        sql = base_sql % (sid, name, age)
        ctx, err = self.db.Exec(sql)
        assert err is None, 'db exec with a err'
        self.usetime = ctx.TimeUsed() * 1000
Esempio n. 2
0
class Transaction(object):
    def __init__(self):
        self.db = BenchDB()
        self.base_sql = "select id, name, age from student where id = %d"
        self.id = 0

    def run(self):
        self.id += 1
        sid = self.id
        base_sql = self.base_sql

        sql = base_sql % (sid)
        ctx, err = self.db.Exec(sql)
        assert err is None, 'db exec with a err'
        self.usetime = ctx.TimeUsed() * 1000
Esempio n. 3
0
class Transaction(object):
    def __init__(self):
        self.db = BenchDB()
        self.base_sql = "update student set age = %d  where id = %d"
        self.id = 0

    def run(self):
        self.id += 1
        sid = self.id
        base_sql = self.base_sql
        
        age = random.uniform(6, 60)
        sql = base_sql % (sid, age)
        ctx, err = self.db.Exec(sql)
        assert err is None, 'db exec with a err'
        self.usetime = ctx.TimeUsed()*1000
Esempio n. 4
0
 def __init__(self):
     self.db = BenchDB()
     self.base_sql = "select id, name, age from student where id = %d"
     self.id = 0
Esempio n. 5
0
 def __init__(self):
     self.db = BenchDB()
     self.base_sql = "delete from student where id = %d"
     self.id = 0
Esempio n. 6
0
 def __init__(self):
     self.db = BenchDB()
     self.base_sql = "update student set age = %d  where id = %d"
     self.id = 0
Esempio n. 7
0
 def __init__(self):
     self.db = BenchDB()
     self.db.delete_db()
     self.base_sql = "insert into student (id, name, age) values (%d, '%s', %d)"
     self.id = 0