timezone.py 2.0 KB
Newer Older
Z
zhaoyanggh 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
from tarfile import SYMTYPE
from time import sleep
from tkinter import E
import taos
import sys

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



class TDTestCase:

    def init(self, conn, logSql):
        tdLog.debug(f"start to excute {__file__}")
        tdSql.init(conn.cursor())

    def run(self):  # sourcery skip: extract-duplicate-method
J
jiacy-jcy 已提交
20
        # for func now() , today(), timezone()
Z
zhaoyanggh 已提交
21 22
        tdSql.prepare()

J
jiacy-jcy 已提交
23
        tdLog.printNoPrefix("==========step1:create tables==========")
Z
zhaoyanggh 已提交
24
        tdSql.execute(
J
jiacy-jcy 已提交
25
            '''create table if not exists ntb
Z
zhaoyanggh 已提交
26 27 28
            (ts timestamp, c1 int, c2 float,c3 double)
            '''
        )
J
jiacy-jcy 已提交
29 30 31 32 33 34 35 36 37 38
        tdSql.execute(
            '''create table if not exists stb
            (ts timestamp, c1 int, c2 float,c3 double) tags(t0 int)
            '''
        )
        tdSql.execute(
            '''create table if not exists stb_1 using stb tags(100)
            '''
        )

J
jiacy-jcy 已提交
39
        tdLog.printNoPrefix("==========step2:insert data==========")
J
jiacy-jcy 已提交
40 41
        tdSql.execute("insert into ntb values(now,10,99.99,11.111111)(today(),100,11.111,22.222222)")
        tdSql.execute("insert into stb_1 values(now,111,99.99,11.111111)(today(),1,11.111,22.222222)")
Z
zhaoyanggh 已提交
42

J
jiacy-jcy 已提交
43 44 45 46
        tdLog.printNoPrefix("==========step3:query data==========")
        tdSql.query("select timezone() from ntb")
        tdSql.checkRows(2)
        tdSql.query("select timezone() from db.ntb")
Z
zhaoyanggh 已提交
47 48
        tdSql.checkRows(2)

J
update  
jiacy-jcy 已提交
49
        tdSql.query("select timezone() from stb")
J
jiacy-jcy 已提交
50 51 52
        tdSql.checkRows(2)
        tdSql.query("select timezone() from db.stb")
        tdSql.checkRows(2)
J
jiacy-jcy 已提交
53

J
jiacy-jcy 已提交
54 55 56 57
        tdSql.query("select timezone() from stb_1")
        tdSql.checkRows(2)
        tdSql.query("select timezone() from db.stb_1 ")
        tdSql.checkRows(2)
J
update  
jiacy-jcy 已提交
58 59
        
        # tdSql.execute()
J
jiacy-jcy 已提交
60 61 62



Z
zhaoyanggh 已提交
63 64 65 66 67 68 69 70


    def stop(self):
        tdSql.close()
        tdLog.success(f"{__file__} successfully executed")

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