import mig_util as mu oraconn = mu.get_oracle_conn() myconn = mu.get_mysql_conn('doodb') table = 'EMPLOYEES' cols = "EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE, JOB_ID, SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID" rand_row_count = 0 with oraconn : ora_cnt = mu.get_count(oraconn, table) cur = oraconn.cursor() sql = "SELECT * FROM (SELECT " + cols + " FROM " + table + " ORDER BY DBMS_RANDOM.RANDOM) WHERE rownum <= 10" cur.execute(sql) ora_list = cur.fetchall() rand_row_count = cur.rowcount with myconn : my_cnt = mu.get_count(myconn ,"Employees") print("이관된 oracle 레코드수", ora_cnt, ", 이관된 mysql 레코드 수 =", my_cnt) if ora_cnt != my_cnt: print("레코드 수가 일치하지 않습니다! oracle=", ora_cnt, ", mysql =", my_cnt) exit()
import mig_util as mu conn_dooodb = mu.get_mysql_conn('dooodb') conn_dadb = mu.get_mysql_conn('dadb') table = 'Subject' # read from source db with conn_dooodb: dooo_cnt = mu.get_count(conn_dooodb, table) with conn_dadb: da_cnt = mu.get_count(conn_dadb, table) print("dooodb =", dooo_cnt, ", dadb =", da_cnt) if dooo_cnt == da_cnt: print("OK") else: print("Not Valid Count!! dooodb =", dooo_cnt, ", dadb =", da_cnt)
import mig_util as mu oraconn = mu.get_oracle_conn() myconn = mu.get_mysql_conn('dooodb') table = 'JOB_HISTORY' cols = "EMPLOYEE_ID, START_DATE, END_DATE, JOB_ID, DEPARTMENT_ID" rand_row_count = 0 with oraconn: ora_cnt = mu.get_count(oraconn, table) cur = oraconn.cursor() sql = "SELECT * FROM (SELECT " + cols + " FROM " + table + " ORDER BY DBMS_RANDOM.RANDOM) WHERE rownum <= 10" cur.execute(sql) ora_list = cur.fetchall() rand_row_count = cur.rowcount with myconn: my_cnt = mu.get_count(myconn, "JobHistory") print("이관된 oracle 레코드수", ora_cnt, ", 이관된 mysql 레코드 수 =", my_cnt) if ora_cnt != my_cnt: print("레코드 수가 일치하지 않습니다! oracle=", ora_cnt, ", mysql =", my_cnt) exit() else: print("레코드 수가 일치합니다.") cur = myconn.cursor() sql = '''select employee_id, start_date, end_date, job_id, department_id
import mig_util as mu oraconn = mu.get_oracle_conn() myconn = mu.get_mysql_conn('dooodb') table = 'JOBS' cols = "JOB_ID, JOB_TITLE, MIN_SALARY, MAX_SALARY" rand_row_count = 0 with oraconn: ora_cnt = mu.get_count(oraconn, table) cur = oraconn.cursor() sql = "SELECT * FROM (SELECT " + cols + " FROM " + table + " ORDER BY DBMS_RANDOM.RANDOM) WHERE rownum <= 10" cur.execute(sql) ora_list = cur.fetchall() rand_row_count = cur.rowcount with myconn : my_cnt = mu.get_count(myconn , "Jobs") print("이관된 oracle 레코드수", ora_cnt, ", 이관된 mysql 레코드 수 =", my_cnt) if ora_cnt != my_cnt: print("레코드 수가 일치하지 않습니다! oracle=", ora_cnt, ", mysql =", my_cnt) exit() else:
table_employees = 'Employees' table_job = 'Job' table_jobs = 'Jobs' table_job_history = 'Job_history' cols_department = "department_id, department_name, manager_id, employee_cnt" cols_departments = "department_id, department_name, manager_id, emp_cnt" cols_employee = "employee_id, first_name, last_name, email, tel, hire_date, job_id, salary, commission_pct, manager_id, department_id" cols_employees = "employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_pct, manager_id, department_id" cols_job = "job_id, job_name, min_salary, max_salary" cols_jobs = "job_id, job_title, min_salary, max_salary" cols_job_history = "employee_id, start_date, end_date, job_id, department_id" cols_job_historys = "employee_id, start_date, end_date, job_id, department_id" rand_row_count = 0 # read from source db with conn_oracle_hr: oracle_departments_cnt = mu.get_count(conn_oracle_hr, table_departments) oracle_employees_cnt = mu.get_count(conn_oracle_hr, table_employees) oracle_jobs_cnt = mu.get_count(conn_oracle_hr, table_jobs) oracle_job_history_cnt = mu.get_count(conn_oracle_hr, table_job_history) cur = conn_oracle_hr.cursor() sql = "select * from (select " + cols_departments + " from " + table_departments + " order by dbms_random.random) where rownum <= :1" sample_rowcount_oracle_departments = round(oracle_departments_cnt / 3) cur.execute(sql, (sample_rowcount_oracle_departments,)) departments_samples = cur.fetchall() sql = "select * from (select " + cols_employees + " from " + table_employees + " order by dbms_random.random) where rownum <= :1"
import mig_util as mu oraconn = mu.get_oracle_conn() myconn = mu.get_mysql_conn('dooodb') table = 'DEPARTMENTS' cols = " DEPARTMENT_ID, DEPARTMENT_NAME, nvl(MANAGER_ID, 0)" rand_row_count = 0 with oraconn: ora_cnt = mu.get_count(oraconn, table) cur = oraconn.cursor() sql = "SELECT * FROM (SELECT " + cols + " FROM " + table + " ORDER BY DBMS_RANDOM.RANDOM) WHERE rownum <= 10" cur.execute(sql) ora_list = cur.fetchall() rand_row_count = cur.rowcount with myconn: my_cnt = mu.get_count(myconn, "Departments") print("이관된 oracle 레코드수", ora_cnt, ", 이관된 mysql 레코드 수 =", my_cnt) if ora_cnt != my_cnt: print("레코드 수가 일치하지 않습니다! oracle=", ora_cnt, ", mysql =", my_cnt) exit() else: print("레코드 수가 일치합니다.") cur = myconn.cursor() sql = '''select id, department_name, manager_id