def test_tmp(self): tables = sch.get_tables( sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'brm_ods')) self.assertTrue(len(tables) > 0) for tab_name in tables: all_idx = sch.get_indexes( sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'BRM_ODS'), tab_name) print str(len(all_idx))
def test_get_record_count(self): self.assertTrue( sch.get_record_count( sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'Cloud_Usage_Events'), 'dbo.CBS_USAGE_EVENTS'.lower()) > 0) self.assertTrue( sch.get_record_count( sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'BRM_ODS'), 'dbo.staging_EVENT_BAL_IMPACTS_T_partition_20151009-134325'. lower()) > 0)
def test_get_min_date(self): min_date = sch.get_min_date( sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'Cloud_Usage_Events'), 'CBS_USAGE_EVENTS'.lower(), 'dw_timestamp', 'dbo', False) self.assertTrue(len(min_date) == 10)
def test_get_columns(self): oneresult = sch.get_columns( sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'Cloud_Usage_Events'), 'vw_BACKUP_BANDWIDTHIN_USAGE_EVENTS'.lower(), 'dbo') self.assertTrue(len(oneresult) > 0) for (name, type) in oneresult: print(name.lower(), type)
def test_compare_table_columns(self): sqlcolumns = sch.get_columns( sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'Cloud_Usage_Events'), 'vw_BACKUP_BANDWIDTHOUT_USAGE_EVENTS'.lower(), 'dbo') hcolumns = hcat.get_table_columns('cloud_usage_events', 'backup_bandwidthout_usage_events') self.assertTrue(len(sqlcolumns) == len(hcolumns)) for i in range(0, len(sqlcolumns)): print 'SQL: {}, Hive:{}'.format(sqlcolumns[i][0], hcolumns[i][0]) self.assertTrue(sqlcolumns[i][0] == hcolumns[i][0])
def test_get_sql_tables(self): self.assertTrue( len( sch.get_tables( sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'Cloud_Usage_Events'))) > 0)
''' Created on Apr 6, 2016 @author: natasha.gajic ''' import datetime import pypyodbc as odbc import hive.schema.maintenence.sqlserver_api as sch run_date = datetime.datetime(2013, 07, 20) end_date = datetime.datetime(2015, 10, 10) run_date += datetime.timedelta(days=1) conn = sch.get_connection('10.12.250.116', 'edwread', 'readedw', 'brm_ods') output_file = open('r_count_output.txt', 'w') while (run_date < end_date): next_date = run_date + datetime.timedelta(days=1) stmt = "select '" + run_date.__str__( )[0: 10] + "', count_big(*) from [dbo].[EVENT_BAL_IMPACTS_T_Archive] where dw_timestamp >= '" + run_date.__str__( ) + "' and dw_timestamp < '" + next_date.__str__() + "';" print stmt curr = conn.cursor() curr.execute(stmt) for row in curr.fetchall(): o = row[0].encode('ascii') + "," + str(row[1]).encode('ascii') + "\n" print o output_file.write(o) run_date = next_date