示例#1
0
    def test_time_range(self):
        time_range_tests = [
            [(None, None), "NULL", "NULL"],
            [(0, 1000000000), "'1970-01-01 00:00:00'", "'2001-09-09 01:46:40'"],
            [
                ("2000-01-01", "2010-01-01"),
                "'2000-01-01 00:00:00'",
                "'2010-01-01 00:00:00'",
            ],
            [
                (datetime.date(2000, 1, 1), datetime.datetime(2010, 1, 1, 0, 0, 0)),
                "'2000-01-01 00:00:00'",
                "'2010-01-01 00:00:00'",
            ],
        ]
        for time_range, start, end in time_range_tests:
            read_td_table("test_table", self.engine, time_range=time_range)
        self.assert_query(
            """
SELECT *
FROM test_table
WHERE td_time_range(time, {0}, {1})
LIMIT 10000
""".format(
                start, end
            )
        )
示例#2
0
文件: test_td.py 项目: yyuu/pandas-td
    def test_with_columns(self):
        read_td_table('test_table', self.engine, columns=['c1', 'c2'])
        self.assert_query('''
SELECT c1, c2
FROM test_table
LIMIT 10000
''')
示例#3
0
    def test_with_columns(self):
        read_td_table('test_table', self.engine, columns=['c1', 'c2'])
        self.assert_query('''
SELECT c1, c2
FROM test_table
LIMIT 10000
''')
示例#4
0
    def test_default(self):
        read_td_table('test_table', self.engine)
        self.assert_query('''
SELECT *
FROM test_table
LIMIT 10000
''')
示例#5
0
文件: test_td.py 项目: yyuu/pandas-td
    def test_default(self):
        read_td_table('test_table', self.engine)
        self.assert_query('''
SELECT *
FROM test_table
LIMIT 10000
''')
示例#6
0
文件: test_td.py 项目: yyuu/pandas-td
    def test_with_sample(self):
        read_td_table('test_table', self.engine, sample=0.1)
        self.assert_query('''
SELECT *
FROM test_table
TABLESAMPLE BERNOULLI (10.0)
LIMIT 10000
''')
示例#7
0
    def test_without_limit(self):
        read_td_table("test_table", self.engine, limit=None)
        self.assert_query(
            """
SELECT *
FROM test_table
"""
        )
示例#8
0
    def test_default(self):
        read_td_table("test_table", self.engine)
        self.assert_query(
            """
SELECT *
FROM test_table
LIMIT 10000
"""
        )
示例#9
0
    def test_with_columns(self):
        read_td_table("test_table", self.engine, columns=["c1", "c2"])
        self.assert_query(
            """
SELECT c1, c2
FROM test_table
LIMIT 10000
"""
        )
示例#10
0
文件: test_td.py 项目: yyuu/pandas-td
    def test_time_range(self):
        time_range_tests = [
            [(None, None), "NULL", "NULL"],
            [(0, 1000000000), "'1970-01-01 00:00:00'", "'2001-09-09 01:46:40'"],
            [('2000-01-01', '2010-01-01'), "'2000-01-01 00:00:00'", "'2010-01-01 00:00:00'"],
            [(datetime.date(2000, 1, 1), datetime.datetime(2010, 1, 1, 0, 0, 0)),
             "'2000-01-01 00:00:00'", "'2010-01-01 00:00:00'"],
        ]
        for time_range, start, end in time_range_tests:
            read_td_table('test_table', self.engine, time_range=time_range)
        self.assert_query('''
SELECT *
FROM test_table
WHERE td_time_range(time, {0}, {1})
LIMIT 10000
'''.format(start, end))
示例#11
0
else:
    qLimit = None

#============output format ===================
try:
    outputFormat = input('would you like to specify output format?yes/no?  ')
except:
    print("something went wrong")

if outputFormat == 'yes':
    outFormat = user_input_script.outputformat()
else:
    outFormat = 'tabular'

#============issue query in treasure data based on user inputs ===================
engine = con.query_engine(database=dbName, type=qEngine)
df = td.read_td_table(tabName,
                      engine,
                      limit=qLimit,
                      time_range=(mintStamp, maxtStamp),
                      columns=colList)
df

#======================Download or display results================================
if outFormat == 'csv':
    df.to_csv('result.csv')
else:
    print(tabulate(df, headers=df.columns, tablefmt="grid"))

#####################################################
示例#12
0
def getdefaultcolumnlist(tabName, dbName, qEngine):
    engine = con.query_engine(database=dbName, type=qEngine)
    df = td.read_td_table(tabName,
                          engine)  #it throw an error bcz of engine!!!!
    colList = list(df.columns.values)
    return colList
示例#13
0
    def test_without_limit(self):
        read_td_table('test_table', self.engine, limit=None)
        self.assert_query('''
SELECT *
FROM test_table
''')
示例#14
0
 def test_invalid_time_range(self):
     with self.assertRaises(ValueError):
         read_td_table("test_table", self.engine, time_range=(1.0, 2.0))
示例#15
0
文件: test_td.py 项目: yyuu/pandas-td
 def test_invalid_time_range(self):
     read_td_table('test_table', self.engine, time_range=(1.0, 2.0))
示例#16
0
 def fetch_table(self, table):
     return td.read_td_table(table, self.engine)
示例#17
0
文件: test_td.py 项目: yyuu/pandas-td
    def test_without_limit(self):
        read_td_table('test_table', self.engine, limit=None)
        self.assert_query('''
SELECT *
FROM test_table
''')
示例#18
0
文件: test_td.py 项目: yyuu/pandas-td
 def test_invalid_sample_small(self):
     read_td_table('test_table', self.engine, sample=-1)
示例#19
0
文件: test_td.py 项目: yyuu/pandas-td
 def test_invalid_sample_large(self):
     read_td_table('test_table', self.engine, sample=1.1)
示例#20
0
 def test_invalid_time_range(self):
     read_td_table('test_table', self.engine, time_range=(1.0, 2.0))