{"id":361579,"date":"2024-05-21T01:16:43","date_gmt":"2024-05-21T01:16:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=361579"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T01:16:43","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=361579","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 Python<\/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>\u041f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0438\u0445\u0430\u0438\u043b, \u044f \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043e\u0442\u0434\u0435\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 <a href=\"https:\/\/bftcom.com\/career\/\">\u0411\u0424\u0422-\u0425\u043e\u043b\u0434\u0438\u043d\u0433\u0430<\/a>. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043f\u043e\u0440\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435: \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0435. \u041e\u043d\u0438 \u0432\u0441\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0435, \u043d\u043e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: \u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u043b\u044e\u0431\u043e\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0411\u0414 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b. \u042d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043a\u0443\u0447\u043d\u043e \u0438 \u043c\u0443\u0442\u043e\u0440\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u043b\u0430 \u0432\u0441\u044e \u0441\u043a\u0443\u0447\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430 \u043c\u0435\u043d\u044f.<\/p>\n<h3>\u0421\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u0441\u044f \u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438. \u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 csv-\u0444\u0430\u0439\u043b. \u0418 \u0442\u0430\u043a \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443.<\/p>\n<p>\u0422.\u043a. \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441 PostgreSQL, \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <code>psycopg2<\/code> \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414.<\/p>\n<pre><code class=\"bash\">> pip install psycopg2-binary <\/code><\/pre>\n<h3>\u041f\u0438\u0448\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u044f \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043b \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043f\u0430\u0440\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 json \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 <code>dict<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u0443 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <code>psycopg2<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>connect()<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0438\u043f\u0443 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 user:<code>postgres<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u044f \u043c\u043e\u0433\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043d\u044b\u0439 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e config.<\/p>\n<pre><code class=\"json\">config.json  {   \"host\": \"255.255.255.255\",   \"port\": \"5432\",   \"database\": \"postgres\",   \"user\": \"postgres\",   \"password\": \"TOP_SECRET\" } <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0431\u044b\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u044b\u043c\u0438, \u0430 \u043d\u0435 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u043c\u0438 \u0431\u0443\u043a\u0432\u0430\u043c\u0438. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 <code>psycopg2.connect()<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>**kwargs<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a <code>**config<\/code> \u0438 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <code>host=\u201d255.255.255.255\u201d, port=\u201d5432\u201d<\/code>, \u0438 \u0442.\u0434.<\/p>\n<p>\u041f\u043b\u044e\u0441\u044b:<\/p>\n<ol>\n<li>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u043c 4 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0449\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435, \u0442.\u043a. \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>config.json<\/code> \u0432 <code>.gitignore<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"python\">def load_config():     # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0442\u0435\u043d\u0438\u044f     with open('config.json', 'r') as config_file:         # \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 json \u0447\u0438\u0442\u0430\u0435\u043c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442         return json.load(config_file)  def db_connect(config):     try:         with pg.connect(**config) as conn:             with conn.cursor() as cur:                 # \u0417\u0434\u0435\u0441\u044c \u0437\u0430\u043f\u0440\u043e\u0441     except Exception as e:         print('\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438:', e) <\/code><\/pre>\n<p>\u0427\u0442\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u0438\u043c? \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0443 <code>try\/except<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0434\u0432\u043e\u0439\u043d\u043e\u0439 with, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414 \u0447\u0435\u0440\u0435\u0437 <code>**config<\/code> (\u043c\u044b \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>load_config<\/code>), \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0443\u0440\u0441\u043e\u0440.<\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043d\u0430\u043c \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 <code>cur.close()<\/code> \u0438 <code>conn.close()<\/code> \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0443\u0434\u0430 \u043e\u043f\u0440\u044f\u0442\u043d\u0435\u0435, \u0447\u0435\u043c:<\/p>\n<pre><code class=\"python\">def db_conn():     conn = psycopg2.connect(user='postgres',                             dbname='postgres',                             host='255.255.255.255',                             port=5432,                             password='TOP_SECRET')     cur = conn.cursor()     # \u0437\u0430\u043f\u0440\u043e\u0441\u044b     cur.close()     conn.close() <\/code><\/pre>\n<h3>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 .sql \u0444\u0430\u0439\u043b\u0430<\/h3>\n<p>\u041c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438\u0441\u044c \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 <code>.sql<\/code> \u0444\u0430\u0439\u043b\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434 <code>.execute()<\/code>.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435:<\/p>\n<ol>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <code>input.sql<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 <code>.csv<\/code> \u0441 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c: \u043a\u043e\u043d\u0442\u0443\u0440_\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441_\u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u044f\u044f \u0434\u0430\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 input.sql:<\/p>\n<pre><code class=\"sql\">select     'table1' as table_name,     increment_id,     source_system_cd,     count(increment_id) as increment_id,     count(source_id_access_level) as source_id_access_level,     count(external_id) as external_id,     --\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b     count(source_party_type) as source_party_type,     count(_update_ts) as _update_ts from buffer_table_access_level where increment_id = %s group by increment_id, source_system_cd;  select     'table2' as table_name,     increment_id,     source_system_cd,     count(source_party_type) as source_party_type,     count(source_system_cd) as source_system_cd,     count(external_id) as external_id,     --\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b     count(source_id_citizenship) as source_id_citizenship,     count(is_deleted) as is_deleted,     count(increment_id) as increment_id from buffer_table_persons where increment_id = %s  group by increment_id, source_system_cd; <\/code><\/pre>\n<p>\u0418\u0437 input.sql \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u0442\u043e\u0447\u043a\u043e\u0439 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439,<\/p>\n<\/li>\n<li>\n<p>\u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c where, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041a\u0430\u043a \u043d\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u043a\u043e\u0434\u0435?<\/h4>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0430\u0439\u0434\u0438:<\/p>\n<pre><code class=\"python\">def get_increments(incur, sys):     select = '''select increment_id                  from increments                  where \"source\" like %s                  order by start_load_ts desc'''     incur.execute(select, (sys,))     increments = incur.fetchall()     return [el[0] for el in increments] <\/code><\/pre>\n<p>\u0427\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u041c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0443\u0440\u0441\u043e\u0440 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a. \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441. \u0412\u0430\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e <code>psycopg2<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441. \u0417\u0430 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f %s, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432 <code>.execute()<\/code> \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 <code>tuple<\/code>. \u0421 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435: (\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, )<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0439\u0434\u0438, \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443:<\/p>\n<pre><code class=\"python\">from datetime import datetime as dt  def naming(action, system):     return f'{\"uat\" if action == else \"prod\"}_{system}_{dt.now().date()}.csv'   def exec(system, action, cur):     increment = get_increments(cur, system)      with (open('input.sql', 'r') as input_file,           open(naming(action, system), 'w', newline='') as csv_file):         queries = input_file.read().split(';')         csv_writer = csv.writer(csv_file)         for query in queries:             cur.execute(query, (0,))             csv_writer.writerow([desc[0] for desc in cur.description])              for inc in increment:                 cur.execute(query, (inc,))                 result = cur.fetchall()                  if len(result) != 0:                     csv_writer.writerows(result)             csv_writer.writerow('') <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043a\u043e\u0434.<\/p>\n<ol>\n<li>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>csv<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>cur.fetchall()<\/code> \u0432 <code>output.csv<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043d\u0435\u0435 <code>system<\/code>, <code>action<\/code>, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0437\u0436\u0435. \u0418 \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043d\u0430\u043c cur.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c input \u0438 output. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e (1) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>with<\/code>, \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u0438 (2) output \u0438\u043c\u0435\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 <code>input.sql<\/code> \u043c\u0435\u0442\u043e\u0434\u043e\u043c read() \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e \u0442\u043e\u0447\u043a\u0435 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>split()<\/code>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e queries. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>csv_writer()<\/code> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>csv<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0446\u0438\u043a\u043b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c, \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043a\u043e\u043b\u043e\u043d\u043e\u043a. \u0422\u0430\u043a \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0447\u0443\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0446\u0438\u043a\u043b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c, \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0443\u0436\u0435 \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0430\u0439\u0434\u0438 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432\u0435\u0440\u043d\u0443\u043b \u043b\u0438 <code>execute<\/code> \u0432\u043e\u043e\u0431\u0449\u0435 \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e) <code>csv_writer<\/code> \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0442\u0430\u043f\u043b\u0430\u043c (\u043e\u0442 \u0441\u043b\u043e\u0432. tuple) \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 csv \u0444\u0430\u0439\u043b.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/e14\/d31\/6d0\/e14d316d0f0a4b583e7cd3f201af1c2b.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e14\/d31\/6d0\/e14d316d0f0a4b583e7cd3f201af1c2b.png\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u0438\u0448\u0435\u043c \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u0438<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0434\u0443\u043c\u0430\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u0432\u0438\u043b \u0438\u0437 \u043e\u043f\u044b\u0442\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u043e\u043c.<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438 \u0436\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u00ab\u0437\u0430\u0432\u0438\u0441\u043b\u0430\u00bb;<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f CLI-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0438\u0445 \u0442\u043e\u0436\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u044f \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u043b <a href=\"https:\/\/habr.com\/ru\/articles\/150950\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<p>\u0410 \u043c\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">def main_menu():     global stop_animation      print('statistic_selector v1 by Ivchik Mikhail')     conf = load_config()      while True:         ask = input('\\n\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435: \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443(G), \u0412\u044b\u0439\u0442\u0438(X): ')         if ask == 'G' or ask == 'g':             action = int(input('\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0443\u0440: 1-\u0443\u0430\u0442, 2-\u043f\u0440\u043e\u0434 [\u043f\u0440\u043e\u0434 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e]: ') or \"2\")             surname = input('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0444\u0430\u043c\u0438\u043b\u0438\u044e \u043a\u0430\u043a \u0432 \u043b\u043e\u0433\u0438\u043d\u0435 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0431\u0434: ')             system = input('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443: ')              conf['database'] = 'your_dbname1' if action == 1 else 'your_dbname2'             conf['user'] = f'{surname}_postfix1' if action == 1 else f'{surname}_postfix2'              animation_thread = threading.Thread(target=animation_func)             stop_animation = False             animation_thread.start()              db_connect(conf, system, action)             os.startfile(naming(action, system))              stop_animation = True             animation_thread.join()             continue         else:             break  if __name__ == \"__main__\":     main_menu()  <\/code><\/pre>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e:<\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0432\u0435\u0440\u0441\u0438\u044e \u0438 \u0438\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0435\u043c \u0432\u0432\u043e\u0434\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e. \u0422\u0443\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u0443\u044e \u0431\u0443\u043a\u0432\u0443 (\u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0442\u043e\u043d).<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>int(input(\u2018\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u043b\u0438 \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0438\u0447\u0435\u0433\u043e\u2019)<\/code> or \u20182\u2019) \u0432\u0435\u0440\u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041b\u0438\u0431\u043e, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u0432\u0435\u0434\u0435\u0442, \u0432\u0435\u0440\u043d\u0435\u0442 2. \u0421\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0443\u0440, \u043b\u043e\u0433\u0438\u043d \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u0430\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435.<\/p>\n<h3>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e<\/h3>\n<p>\u041f\u0438\u0442\u043e\u043d \u2014 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u044f\u0437\u044b\u043a. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435 \u043d\u0430\u0447\u043d\u0435\u0442\u0441\u044f. \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u2013 \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0435\u0441\u043b\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0446\u0438\u043a\u043b <code>for<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043f\u0438\u0448\u0435\u0442 \u00ab\u041f\u0440\u0438\u0432\u0435\u0442\u00bb, \u0446\u0438\u043a\u043b \u043d\u0430\u0447\u043d\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u00ab\u041f\u0440\u0438\u0432\u0435\u0442\u00bb \u043b\u0438\u0431\u043e \u0434\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043b\u0438\u0431\u043e \u043f\u043e\u0441\u043b\u0435. <strong>\u041d\u043e \u043d\u0435 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c<\/strong>. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0435\u0439. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f, \u043f\u043e\u0432\u0442\u043e\u0440\u044e\u0441\u044c, \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<p>\u041d\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0434\u0442\u0438 \u0434\u043e \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 threading, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0439 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c. \u041e\u043d \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f. \u0417\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u041c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043d\u0430 False. \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e, \u0438 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043a \u0441\u0442\u0440\u043e\u0447\u043a\u0435 continue.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u043e\u0434 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, \u043d\u0430\u0448\u0435\u043b \u043d\u0430 <a href=\"https:\/\/stackoverflow.com\/questions\/7039114\/waiting-animation-in-command-prompt-python\">\u043e\u0432\u0435\u0440\u0444\u043b\u043e\u0443<\/a>:<\/p>\n<pre><code class=\"python\">def animation_func():    global stop_animation    animation = \"|\/-\\\\\"    idx = 0    while not stop_animation:        print(animation[idx % len(animation)], end=\"\\r\")        idx += 1        time.sleep(0.1)   def run_animation():    animation_func() <\/code><\/pre>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e34\/296\/3d5\/e342963d5ec5de0434475ca4eee630be.gif\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e34\/296\/3d5\/e342963d5ec5de0434475ca4eee630be.gif\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u0432\u0441\u0435.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 .exe \u0444\u0430\u0439\u043b \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 pyinstaller:<\/p>\n<pre><code class=\"bash\">> pip install pyinstaller > pyinstaller --onefile main.py <\/code><\/pre>\n<h3>\u0414\u0435\u043b\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043c\u043e\u0436\u0435\u0442 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0443\u0439\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430\u043c. \u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 union all \u0432 PostgreSQL, \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e: \u0443 \u0432\u0430\u0441 \u043d\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0438 \u0432\u043e\u0437\u043d\u0438 \u0441 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u043a\u0440\u0438\u043f\u0442 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0432 \u0442.\u0447. \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e, \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041d\u043e \u0441\u0430\u043c\u0430 \u0438\u0434\u0435\u044f \u0441\u043a\u043b\u0435\u0439\u043a\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043e\u0434\u043d\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u044f \u0434\u0443\u043c\u0430\u044e, \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c.<\/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\/777348\/\"> https:\/\/habr.com\/ru\/articles\/777348\/<\/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>\u041f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0438\u0445\u0430\u0438\u043b, \u044f \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043e\u0442\u0434\u0435\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 <a href=\"https:\/\/bftcom.com\/career\/\">\u0411\u0424\u0422-\u0425\u043e\u043b\u0434\u0438\u043d\u0433\u0430<\/a>. \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043f\u043e\u0440\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435: \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0435. \u041e\u043d\u0438 \u0432\u0441\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0435, \u043d\u043e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: \u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u043b\u044e\u0431\u043e\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0411\u0414 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b. \u042d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043a\u0443\u0447\u043d\u043e \u0438 \u043c\u0443\u0442\u043e\u0440\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u043b\u0430 \u0432\u0441\u044e \u0441\u043a\u0443\u0447\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430 \u043c\u0435\u043d\u044f.<\/p>\n<h3>\u0421\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u0441\u044f \u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c\u0438. \u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 csv-\u0444\u0430\u0439\u043b. \u0418 \u0442\u0430\u043a \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443.<\/p>\n<p>\u0422.\u043a. \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441 PostgreSQL, \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <code>psycopg2<\/code> \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414.<\/p>\n<pre><code class=\"bash\">> pip install psycopg2-binary <\/code><\/pre>\n<h3>\u041f\u0438\u0448\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u044f \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043b \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043f\u0430\u0440\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 json \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 <code>dict<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0430\u0440\u0443 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 <code>psycopg2<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>connect()<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0438\u043f\u0443 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 user:<code>postgres<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u044f \u043c\u043e\u0433\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043d\u044b\u0439 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e config.<\/p>\n<pre><code class=\"json\">config.json  {   \"host\": \"255.255.255.255\",   \"port\": \"5432\",   \"database\": \"postgres\",   \"user\": \"postgres\",   \"password\": \"TOP_SECRET\" } <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0431\u044b\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u044b\u043c\u0438, \u0430 \u043d\u0435 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u043c\u0438 \u0431\u0443\u043a\u0432\u0430\u043c\u0438. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 <code>psycopg2.connect()<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>**kwargs<\/code>. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a <code>**config<\/code> \u0438 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <code>host=\u201d255.255.255.255\u201d, port=\u201d5432\u201d<\/code>, \u0438 \u0442.\u0434.<\/p>\n<p>\u041f\u043b\u044e\u0441\u044b:<\/p>\n<ol>\n<li>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u043c 4 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0449\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435, \u0442.\u043a. \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>config.json<\/code> \u0432 <code>.gitignore<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"python\">def load_config():     # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0442\u0435\u043d\u0438\u044f     with open('config.json', 'r') as config_file:         # \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 json \u0447\u0438\u0442\u0430\u0435\u043c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442         return json.load(config_file)  def db_connect(config):     try:         with pg.connect(**config) as conn:             with conn.cursor() as cur:                 # \u0417\u0434\u0435\u0441\u044c \u0437\u0430\u043f\u0440\u043e\u0441     except Exception as e:         print('\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438:', e) <\/code><\/pre>\n<p>\u0427\u0442\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u0438\u043c? \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0443 <code>try\/except<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0434\u0432\u043e\u0439\u043d\u043e\u0439 with, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414 \u0447\u0435\u0440\u0435\u0437 <code>**config<\/code> (\u043c\u044b \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>load_config<\/code>), \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0443\u0440\u0441\u043e\u0440.<\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043d\u0430\u043c \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 <code>cur.close()<\/code> \u0438 <code>conn.close()<\/code> \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0443\u0434\u0430 \u043e\u043f\u0440\u044f\u0442\u043d\u0435\u0435, \u0447\u0435\u043c:<\/p>\n<pre><code class=\"python\">def db_conn():     conn = psycopg2.connect(user='postgres',                             dbname='postgres',                             host='255.255.255.255',                             port=5432,                             password='TOP_SECRET')     cur = conn.cursor()     # \u0437\u0430\u043f\u0440\u043e\u0441\u044b     cur.close()     conn.close() <\/code><\/pre>\n<h3>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 .sql \u0444\u0430\u0439\u043b\u0430<\/h3>\n<p>\u041c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0438\u0441\u044c \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 <code>.sql<\/code> \u0444\u0430\u0439\u043b\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434 <code>.execute()<\/code>.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435:<\/p>\n<ol>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <code>input.sql<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 <code>.csv<\/code> \u0441 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c: \u043a\u043e\u043d\u0442\u0443\u0440_\u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441_\u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u044f\u044f \u0434\u0430\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 input.sql:<\/p>\n<pre><code class=\"sql\">select     'table1' as table_name,     increment_id,     source_system_cd,     count(increment_id) as increment_id,     count(source_id_access_level) as source_id_access_level,     count(external_id) as external_id,     --\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b     count(source_party_type) as source_party_type,     count(_update_ts) as _update_ts from buffer_table_access_level where increment_id = %s group by increment_id, source_system_cd;  select     'table2' as table_name,     increment_id,     source_system_cd,     count(source_party_type) as source_party_type,     count(source_system_cd) as source_system_cd,     count(external_id) as external_id,     --\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b     count(source_id_citizenship) as source_id_citizenship,     count(is_deleted) as is_deleted,     count(increment_id) as increment_id from buffer_table_persons where increment_id = %s  group by increment_id, source_system_cd; <\/code><\/pre>\n<p>\u0418\u0437 input.sql \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u0442\u043e\u0447\u043a\u043e\u0439 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439,<\/p>\n<\/li>\n<li>\n<p>\u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c where, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041a\u0430\u043a \u043d\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u043a\u043e\u0434\u0435?<\/h4>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0430\u0439\u0434\u0438:<\/p>\n<pre><code class=\"python\">def get_increments(incur, sys):     select = '''select increment_id                  from increments                  where \"source\" like %s                  order by start_load_ts desc'''     incur.execute(select, (sys,))     increments = incur.fetchall()     return [el[0] for el in increments] <\/code><\/pre>\n<p>\u0427\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u041c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0443\u0440\u0441\u043e\u0440 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a. \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441. \u0412\u0430\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e <code>psycopg2<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441. \u0417\u0430 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f %s, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432 <code>.execute()<\/code> \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 <code>tuple<\/code>. \u0421 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435: (\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, )<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0439\u0434\u0438, \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443:<\/p>\n<pre><code class=\"python\">from datetime import datetime as dt  def naming(action, system):     return f'{\"uat\" if action == else \"prod\"}_{system}_{dt.now().date()}.csv'   def exec(system, action, cur):     increment = get_increments(cur, system)      with (open('input.sql', 'r') as input_file,           open(naming(action, system), 'w', newline='') as csv_file):         queries = input_file.read().split(';')         csv_writer = csv.writer(csv_file)         for query in queries:             cur.execute(query, (0,))             csv_writer.writerow([desc[0] for desc in cur.description])              for inc in increment:                 cur.execute(query, (inc,))                 result = cur.fetchall()                  if len(result) != 0:                     csv_writer.writerows(result)             csv_writer.writerow('') <\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043a\u043e\u0434.<\/p>\n<ol>\n<li>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>csv<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>cur.fetchall()<\/code> \u0432 <code>output.csv<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043d\u0435\u0435 <code>system<\/code>, <code>action<\/code>, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0437\u0436\u0435. \u0418 \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043d\u0430\u043c cur.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c input \u0438 output. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e (1) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>with<\/code>, \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u0438 (2) output \u0438\u043c\u0435\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 <code>input.sql<\/code> \u043c\u0435\u0442\u043e\u0434\u043e\u043c read() \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e \u0442\u043e\u0447\u043a\u0435 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>split()<\/code>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e queries. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>csv_writer()<\/code> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>csv<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0446\u0438\u043a\u043b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c, \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043a\u043e\u043b\u043e\u043d\u043e\u043a. \u0422\u0430\u043a \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0447\u0443\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0446\u0438\u043a\u043b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c, \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0443\u0436\u0435 \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0430\u0439\u0434\u0438 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432\u0435\u0440\u043d\u0443\u043b \u043b\u0438 <code>execute<\/code> \u0432\u043e\u043e\u0431\u0449\u0435 \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e) <code>csv_writer<\/code> \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0442\u0430\u043f\u043b\u0430\u043c (\u043e\u0442 \u0441\u043b\u043e\u0432. tuple) \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 csv \u0444\u0430\u0439\u043b.<\/p>\n<figure class=\"\">\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u0438\u0448\u0435\u043c \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u0438<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0434\u0443\u043c\u0430\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u0432\u0438\u043b \u0438\u0437 \u043e\u043f\u044b\u0442\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u043e\u043c.<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438 \u0436\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u00ab\u0437\u0430\u0432\u0438\u0441\u043b\u0430\u00bb;<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044e, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f CLI-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0438\u0445 \u0442\u043e\u0436\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c. \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u044f \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u043b <a href=\"https:\/\/habr.com\/ru\/articles\/150950\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<p>\u0410 \u043c\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">def main_menu():     global stop_animation      print('statistic_selector v1 by Ivchik Mikhail')     conf = load_config()      while True:         ask = input('\\n\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435: \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443(G), \u0412\u044b\u0439\u0442\u0438(X): ')         if ask == 'G' or ask == 'g':             action = int(input('\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0443\u0440: 1-\u0443\u0430\u0442, 2-\u043f\u0440\u043e\u0434 [\u043f\u0440\u043e\u0434 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e]: ') or \"2\")             surname = input('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0444\u0430\u043c\u0438\u043b\u0438\u044e \u043a\u0430\u043a \u0432 \u043b\u043e\u0433\u0438\u043d\u0435 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0431\u0434: ')             system = input('\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443: ')              conf['database'] = 'your_dbname1' if action == 1 else 'your_dbname2'             conf['user'] = f'{surname}_postfix1' if action == 1 else f'{surname}_postfix2'              animation_thread = threading.Thread(target=animation_func)             stop_animation = False             animation_thread.start()              db_connect(conf, system, action)             os.startfile(naming(action, system))              stop_animation = True             animation_thread.join()             continue         else:             break  if __name__ == \"__main__\":     main_menu()  <\/code><\/pre>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e:<\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u0432\u0435\u0440\u0441\u0438\u044e \u0438 \u0438\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b;<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0434\u0430\u0435\u043c \u0432\u0432\u043e\u0434\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e. \u0422\u0443\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u0443\u044e \u0431\u0443\u043a\u0432\u0443 (\u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0442\u043e\u043d).<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>int(input(\u2018\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u043b\u0438 \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0438\u0447\u0435\u0433\u043e\u2019)<\/code> or \u20182\u2019) \u0432\u0435\u0440\u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041b\u0438\u0431\u043e, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u0432\u0435\u0434\u0435\u0442, \u0432\u0435\u0440\u043d\u0435\u0442 2. \u0421\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0443\u0440, \u043b\u043e\u0433\u0438\u043d \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u0430\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435.<\/p>\n<h3>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e<\/h3>\n<p>\u041f\u0438\u0442\u043e\u043d \u2014 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u044f\u0437\u044b\u043a. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435 \u043d\u0430\u0447\u043d\u0435\u0442\u0441\u044f. \u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u2013 \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442,<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-361579","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/361579","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=361579"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/361579\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=361579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=361579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=361579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}