{"id":436783,"date":"2024-11-02T21:01:31","date_gmt":"2024-11-02T21:01:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=436783"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=436783","title":{"rendered":"<span>\u0413\u0434\u0435 \u0446\u0438\u043a\u043b\u0443 while \u043d\u0435\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0423\u0432\u0435\u0440\u0435\u043d \u043c\u043d\u043e\u0433\u0438\u0435 \u0442\u0440\u0443-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0438 \u0431\u0435\u0437 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0437\u043d\u0430\u044e\u0442, \u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b\u0441\u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 while, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c, \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0442\u043e\u0440, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a ETL.<\/p>\n<h2>while not all(check_list)<\/h2>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0432 \u0434\u0440\u0443\u0433\u0443\u044e, \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043d\u0435 \u043e\u0434\u043d\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0430 \u0434\u0432\u0435 \u0438 \u0431\u043e\u043b\u0435\u0435. \u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438, \u0437\u043d\u0430\u0447\u0438\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0430 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0435 \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0432\u0437\u044f\u0442\u044b\u0435 \u0441 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430:<\/p>\n<pre><code class=\"sql\">-- SQL  delete from my_shema.my_table        where my_column = 'my_variable';  commit;  insert into my_shema.my_table       select *         from my_shema.my_table@src_dblink        where my_column = 'my_variable'; commit;<\/code><\/pre>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0430\u0437\u0438\u0442\u044c \u043f\u043e \u0441\u0445\u0435\u043c\u0435 \u0438 \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 ORA-02291 \u0438 ORA-02292 (\u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0435 \u0443\u0434\u0430\u043b\u0438\u0432 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u0432\u0441\u0442\u0430\u0432\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443).<\/p>\n<p>\u0413\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0437\u0430\u0442\u0435\u043c \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u0443\u044e \u0432\u0441\u0442\u0430\u0432\u043a\u0443.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0411\u0414 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c DML-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0438\u043a\u043b <strong>while not all(check_list)<\/strong>:<\/p>\n<pre><code class=\"python\"># python3.8 import cx_Oracle   # \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0435\u043a-\u043b\u0438\u0441\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445,  # \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 0, \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d\u044b, \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0435\u0441\u043b\u0438 1 etl_objects = [('MY_SCHEMA', 'MY_TABLE1'), ('MY_SCHEMA', 'MY_TABLE2'), ...] check_list = [0 for _ in range(len(etl_objects))] i = 0 while not all(check_list):   i = i % len(check_list)  # \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0446\u0438\u043a\u043b\u043e\u0432   try:     if not check_list[i]:       with cx_Oracle.connect(user=user,                              password=password,                              tns=tns,                              encoding='utf-8') as db_conn:         with db_conn.cursor() as cursor:           sql_text = (f\"delete from {etl_objects[i][0]}.{etl_objects[i][1]} \"                       \"where my_column = 'my_variable'\")           cursor.execute(sql_text)           cursor.execute('commit')           sql_text = (f\"insert into {etl_objects[i][0]}.{etl_objects[i][1]} \"                       \"select * \"                       f\"from {etl_objects[i][0]}.{etl_objects[i][1]}@src_dblink \"                       \"where my_column = 'my_variable';\")           cursor.execute(sql_text)           cursor.execute('commit')       check_list[i] = 1   except Exception as e:     print(f\"\u0421\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 {str(e)}: \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438\")   i += 1   <\/code><\/pre>\n<p>\u041f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043d\u043e \u0446\u0438\u043a\u043b <strong>while<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0442 ORA-02291 \u0438 ORA-02292, \u0442\u043e \u0446\u0438\u043a\u043b \u0440\u0438\u0441\u043a\u0443\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c, \u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0438 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435.<\/p>\n<h2>while i &lt; len(table_trg) and j &lt; len(table_src)<\/h2>\n<p>\u041f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 DDL \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u044b \u043f\u043e\u043b\u0435\u0439 \u0438 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f. \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430\u044f, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0445\u0440\u0430\u043d\u044f\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043d\u0430\u0431\u043e\u0440 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043f\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f, \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 oracle \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u043b\u0435\u0439 \u0438 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<pre><code class=\"sql\">-- SQL  select column_name, data_type, data_length ,...,    from all_tab_columns  where owner = 'MY_SHEMA' and table_name = 'MY_TABLE';  select column_name, data_type, data_length ,...,    from all_tab_columns@src_dblink  where owner = 'MY_SHEMA' and table_name = 'MY_TABLE';<\/code><\/pre>\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0436\u0438\u0432\u0443\u0442 \u0441\u0432\u043e\u0438\u043c\u0438 \u0436\u0438\u0437\u043d\u044f\u043c\u0438 \u0438 \u043e\u0434\u043d\u0430 \u0436\u0438\u0437\u043d\u044c \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u0432 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439. \u0422\u0430\u043a \u0432\u043e\u0442, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0432 \u0447\u0435\u043c \u043e\u043d\u0430 \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u0438\u043b\u0438 \u0432 \u0447\u0435\u043c \u043e\u043d\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\"># python3.8 import cx_Oracle   with cx_Oracle.connect(user=user,                        password=password,                        tns=tns,                        encoding='utf-8') as db_conn:   with db_conn.cursor() as cursor:     sql_text = (\"select column_name, data_type, data_length \"                 \"from all_tab_columns \"                 \"where owner = 'MY_SHEMA' and table_name = 'MY_TABLE' \"                 \"order by column_name\")     cursor.execute(sql_text)     table_trg = cursor.fetchall()     sql_text = (\"select column_name, data_type, data_length \"                 \"from all_tab_columns@src_dblink \"                 \"where owner = 'MY_SHEMA' and table_name = 'MY_TABLE' \"                 \"order by column_name\")     cursor.execute(sql_text)     table_src = cursor.fetchall()  i, j = 0, 0 tmp_table_trg, tmp_table_src = [], [] while i &lt; len(table_trg) and j &lt; len(table_src):   if table_trg[i][0] == table_src[j][0]:  # \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439     tmp_table_trg.append(table_trg[i])     tmp_table_src.append(table_src[j])     i += 1     j += 1   elif table_trg[i][0] &lt; table_src[j][0]:   # \u0435\u0441\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043c\u0435\u043d\u044c\u0448\u0435, \u0442\u043e \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u043e\u043b\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0435\u0442     tmp_table_trg.append(table_trg[i])     tmp_table_src.append((None, None, None))  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \"\u043f\u0443\u0441\u0442\u0443\u044e\" \u0441\u0442\u0440\u043e\u043a\u0443     i += 1   else:     tmp_table_trg.append((None, None, None))  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043b\u0435\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \"\u043f\u0443\u0441\u0442\u0443\u044e\" \u0441\u0442\u0440\u043e\u043a\u0443     tmp_table_src.append(table_src[j])     j += 1  diffs = list(filter(lambda x: x[0] != x[1], zip(tmp_table_trg, tmp_table_src))) <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <strong>while<\/strong> \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 ( <strong>while not all() <\/strong>) \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0433\u043e\u043d\u044f\u0442\u044c \u0446\u0438\u043a\u043b\u044b \u043f\u043e \u0447\u0435\u043a-\u043b\u0438\u0441\u0442\u0430\u043c, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 ( <strong>while i &lt; len(table_trg) and j &lt; len(table_src)<\/strong> ), \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043a\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0439 \u043a\u043e\u0434 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0411\u0414, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 <strong>csv<\/strong>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/853682\/\"> https:\/\/habr.com\/ru\/articles\/853682\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0423\u0432\u0435\u0440\u0435\u043d \u043c\u043d\u043e\u0433\u0438\u0435 \u0442\u0440\u0443-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0438 \u0431\u0435\u0437 \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0437\u043d\u0430\u044e\u0442, \u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b\u0441\u044f \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 while, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c, \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0442\u043e\u0440, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a ETL.<\/p>\n<h2>while not all(check_list)<\/h2>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0432 \u0434\u0440\u0443\u0433\u0443\u044e, \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043d\u0435 \u043e\u0434\u043d\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0430 \u0434\u0432\u0435 \u0438 \u0431\u043e\u043b\u0435\u0435. \u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438, \u0437\u043d\u0430\u0447\u0438\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0430 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0435 \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0432\u0437\u044f\u0442\u044b\u0435 \u0441 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430:<\/p>\n<pre><code class=\"sql\">-- SQL  delete from my_shema.my_table        where my_column = 'my_variable';  commit;  insert into my_shema.my_table       select *         from my_shema.my_table@src_dblink        where my_column = 'my_variable'; commit;<\/code><\/pre>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0430\u0437\u0438\u0442\u044c \u043f\u043e \u0441\u0445\u0435\u043c\u0435 \u0438 \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 ORA-02291 \u0438 ORA-02292 (\u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0435 \u0443\u0434\u0430\u043b\u0438\u0432 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u0432\u0441\u0442\u0430\u0432\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443).<\/p>\n<p>\u0413\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0437\u0430\u0442\u0435\u043c \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u0443\u044e \u0432\u0441\u0442\u0430\u0432\u043a\u0443.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0411\u0414 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c DML-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0438\u043a\u043b <strong>while not all(check_list)<\/strong>:<\/p>\n<pre><code class=\"python\"># python3.8 import cx_Oracle   # \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0435\u043a-\u043b\u0438\u0441\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445,  # \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 0, \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d\u044b, \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0435\u0441\u043b\u0438 1 etl_objects = [('MY_SCHEMA', 'MY_TABLE1'), ('MY_SCHEMA', 'MY_TABLE2'), ...] check_list = [0 for _ in range(len(etl_objects))] i = 0 while not all(check_list):   i = i % len(check_list)  # \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0446\u0438\u043a\u043b\u043e\u0432   try:     if not check_list[i]:       with cx_Oracle.connect(user=user,                              password=password,                              tns=tns,                              encoding='utf-8') as db_conn:         with db_conn.cursor() as cursor:           sql_text = (f\"delete from {etl_objects[i][0]}.{etl_objects[i][1]} \"                       \"where my_column = 'my_variable'\")           cursor.execute(sql_text)           cursor.execute('commit')           sql_text = (f\"insert into {etl_objects[i][0]}.{etl_objects[i][1]} \"                       \"select * \"                       f\"from {etl_objects[i][0]}.{etl_objects[i][1]}@src_dblink \"                       \"where my_column = 'my_variable';\")           cursor.execute(sql_text)           cursor.execute('commit')       check_list[i] = 1   except Exception as e:     print(f\"\u0421\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 {str(e)}: \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438\")   i += 1   <\/code><\/pre>\n<p>\u041f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0435\u0446 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043d\u043e \u0446\u0438\u043a\u043b <strong>while<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0435 \u0434\u0435\u043b\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0442 ORA-02291 \u0438 ORA-02292, \u0442\u043e \u0446\u0438\u043a\u043b \u0440\u0438\u0441\u043a\u0443\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c, \u043d\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0438 \u043f\u0440\u0438\u0435\u043c\u043d\u0438\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043c\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435.<\/p>\n<h2>while i &lt; len(table_trg) and j &lt; len(table_src)<\/h2>\n<p>\u041f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 DDL \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u044b \u043f\u043e\u043b\u0435\u0439 \u0438 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f. \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430\u044f, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0445\u0440\u0430\u043d\u044f\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043d\u0430\u0431\u043e\u0440 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043f\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f, \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 oracle \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u043b\u0435\u0439 \u0438 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<pre><code class=\"sql\">-- SQL  select column_name, data_type, data_length ,...,    from all_tab_columns  where owner = 'MY_SHEMA' and table_name = 'MY_TABLE';  select column_name, data_type, data_length ,...,    from all_tab_columns@src_dblink  where owner = 'MY_SHEMA' and table_name = 'MY_TABLE';<\/code><\/pre>\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0436\u0438\u0432\u0443\u0442 \u0441\u0432\u043e\u0438\u043c\u0438 \u0436\u0438\u0437\u043d\u044f\u043c\u0438 \u0438 \u043e\u0434\u043d\u0430 \u0436\u0438\u0437\u043d\u044c \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u0432 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439. \u0422\u0430\u043a \u0432\u043e\u0442, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0432 \u0447\u0435\u043c \u043e\u043d\u0430 \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u0438\u043b\u0438 \u0432 \u0447\u0435\u043c \u043e\u043d\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"python\"># python3.8 import cx_Oracle   with cx_Oracle.connect(user=user,                        password=password,                        tns=tns,                        encoding='utf-8') as db_conn:   with db_conn.cursor() as cursor:     sql_text = (\"select column_name, data_type, data_length \"                 \"from all_tab_columns \"                 \"where owner = 'MY_SHEMA' and table_name = 'MY_TABLE' \"                 \"order by column_name\")     cursor.execute(sql_text)     table_trg = cursor.fetchall()     sql_text = (\"select column_name, data_type, data_length \"                 \"from all_tab_columns@src_dblink \"                 \"where owner = 'MY_SHEMA' and table_name = 'MY_TABLE' \"                 \"order by column_name\")     cursor.execute(sql_text)     table_src = cursor.fetchall()  i, j = 0, 0 tmp_table_trg, tmp_table_src = [], [] while i &lt; len(table_trg) and j &lt; len(table_src):   if table_trg[i][0] == table_src[j][0]:  # \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439     tmp_table_trg.append(table_trg[i])     tmp_table_src.append(table_src[j])     i += 1     j += 1   elif table_trg[i][0] &lt; table_src[j][0]:   # \u0435\u0441\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043c\u0435\u043d\u044c\u0448\u0435, \u0442\u043e \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u043e\u043b\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0435\u0442     tmp_table_trg.append(table_trg[i])     tmp_table_src.append((None, None, None))  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0440\u0430\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \"\u043f\u0443\u0441\u0442\u0443\u044e\" \u0441\u0442\u0440\u043e\u043a\u0443     i += 1   else:     tmp_table_trg.append((None, None, None))  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043b\u0435\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \"\u043f\u0443\u0441\u0442\u0443\u044e\" \u0441\u0442\u0440\u043e\u043a\u0443     tmp_table_src.append(table_src[j])     j += 1  diffs = list(filter(lambda x: x[0] != x[1], zip(tmp_table_trg, tmp_table_src))) <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <strong>while<\/strong> \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0432 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 ( <strong>while not all() <\/strong>) \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0433\u043e\u043d\u044f\u0442\u044c \u0446\u0438\u043a\u043b\u044b \u043f\u043e \u0447\u0435\u043a-\u043b\u0438\u0441\u0442\u0430\u043c, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 ( <strong>while i &lt; len(table_trg) and j &lt; len(table_src)<\/strong> ), \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043a\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0439 \u043a\u043e\u0434 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0411\u0414, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 <strong>csv<\/strong>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/853682\/\"> https:\/\/habr.com\/ru\/articles\/853682\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-436783","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/436783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=436783"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/436783\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=436783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=436783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=436783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}