db_table.py 1.5 KB
Newer Older
sangshuduo's avatar
sangshuduo 已提交
1 2 3 4 5 6 7 8 9
# -*- coding: utf-8 -*-

import sys
from util.log import *
from util.cases import *
from util.sql import *


class TDTestCase:
S
Shuduo Sang 已提交
10
    def init(self, conn, logSql):
sangshuduo's avatar
sangshuduo 已提交
11
        tdLog.debug("start to execute %s" % __file__)
S
Shuduo Sang 已提交
12
        tdSql.init(conn.cursor(), logSql)
sangshuduo's avatar
sangshuduo 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

    def run(self):
        tdSql.prepare()

        tdLog.info('=============== step1')
        tdLog.info('=============== step2')
        tdLog.info('create table tb (ts timestamp, speed int)')
        tdSql.execute('create table tb (ts timestamp, speed int)')
        tdLog.info('=============== step3')
        tdLog.info("insert into tb values (now, 1)")
        tdSql.execute("insert into tb values (now, 1)")
        tdLog.info('=============== step4')
        tdLog.info('select * from tb')
        tdSql.query('select * from tb')
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        tdLog.info('=============== step5')
        tdLog.info('describe tb')
        tdSql.query('describe tb')
        tdLog.info('=============== step6')
        tdLog.info('drop database db')
        tdSql.execute('drop database db')
        tdLog.info('show databases')
        tdSql.query('show databases')
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
# convert end

    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)


tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())