{"id":307787,"date":"2020-07-31T09:00:41","date_gmt":"2020-07-31T09:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=307787"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=307787","title":{"rendered":"\u041a\u0430\u043a \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u044b\u043d\u043e\u043a \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python (2\/3). \u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/512208\/\">\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/504900\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0440\u044b\u043d\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430: \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439, \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043b\u043e\u0432, \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0437\u0430\u043b\u0430 \u0434\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0431\u0440\u043e\u043d\u0438.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043a\u044d\u0448\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e:   <\/p>\n<ul>\n<li>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 SQLite \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445; <\/li>\n<li>\u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c Python; <\/li>\n<li>\u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 DataFrame; <\/li>\n<li>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0411\u0414. <\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tv\/_n\/cp\/tv_ncpotzlttmr8op_izcdawn58.jpeg\"><br \/>  <a name=\"habracut\"><\/a><\/p>\n<h3>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a \u0411\u0414 \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443: \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c.<\/p>\n<p>  \u041d\u0430\u0448\u0435\u0439 \u0411\u0414 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f:   <\/p>\n<ul>\n<li>\u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0445\u0435\u043c\u0430\u043c, \u0442.\u043a. \u0434\u043e\u0441\u0442\u0443\u043f \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c;<\/li>\n<li>\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f 24\/7, \u0442.\u043a. \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430;<\/li>\n<li>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440, \u0442.\u043a. \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 python.<\/li>\n<\/ul>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 SQLite. \u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0444\u0430\u0439\u043b\u0430 \u043b\u0438\u0431\u043e \u043d\u0430 \u0436\u0435\u0441\u0442\u043a\u043e\u043c \u0434\u0438\u0441\u043a\u0435, \u043b\u0438\u0431\u043e \u043d\u0430 \u0444\u043b\u0435\u0448\u043a\u0435, \u043b\u0438\u0431\u043e \u043d\u0430 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u043c \u0434\u0438\u0441\u043a\u0435 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432.<\/p>\n<h3>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 SQLite \u0447\u0435\u0440\u0435\u0437 python<\/h3>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 SQLite \u0447\u0435\u0440\u0435\u0437 python \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/www.sqlite.org\/index.html\" rel=\"nofollow\">sqlite3<\/a>.<br \/>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:  <\/p>\n<pre><code class=\"python\">sqlite3.connect(\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443)<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043d\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430.<\/p>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0431\u0430\u0437\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"python\">conn = sqlite3.connect(\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443) cur = conn.cursor() cur.execute(\u0437\u0430\u043f\u0440\u043e\u0441) df = cur.fetchall() <\/code><\/pre>\n<p>  cur.fetchall() \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0411\u0414.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0411\u0414 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"python\">conn.commit() <\/code><\/pre>\n<p>  \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0435\u0451 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c:  <\/p>\n<pre><code class=\"python\"> conn.close() <\/code><\/pre>\n<p>  \u0438\u043d\u0430\u0447\u0435 \u0431\u0430\u0437\u0430 \u0431\u0443\u0434\u0435\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043b\u0438 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435:  <\/p>\n<pre><code class=\"sql\">CREATE TABLE t1 (\u043f\u043e\u043b\u04351 \u0442\u0438\u043f, \u043f\u043e\u043b\u04352 \u0442\u0438\u043f...) <\/code><\/pre>\n<p>  \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0451 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f:  <\/p>\n<pre><code class=\"sql\">CREATE TABLE IF NOT EXISTS t1 (\u043f\u043e\u043b\u04351 \u0442\u0438\u043f, \u043f\u043e\u043b\u04352 \u0442\u0438\u043f...)<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0438\u0437\u0431\u0435\u0433\u0430\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432:  <\/p>\n<pre><code class=\"sql\">INSERT OR IGNORE INTO t1 (\u043f\u043e\u043b\u04351, \u043f\u043e\u043b\u04352, ...) VALUES(\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u04351, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u04352, ...)<\/code><\/pre>\n<p>  \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435:  <\/p>\n<pre><code class=\"sql\">UPDATE t1 SET \u043f\u043e\u043b\u04351 = \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u04351 WHERE \u043f\u043e\u043b\u04352 = \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u04352<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 SQLite \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/sqlite-manager\/njognipnngillknkhikjecpnbkefclfe\" rel=\"nofollow\">SQLite Manager<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/sqlitebrowser.org\/dl\/\" rel=\"nofollow\">DB Browser for SQLite<\/a>.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u043a \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0431\u043b\u043e\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/0c\/xe\/3b\/0cxe3beslffv1r9dtnvlvrvvxyu.png\"><\/p>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u2014 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 desktop-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ko\/ii\/jy\/koiijyodmqpnbt86b1nwyfc3_jc.png\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/of\/az\/vv\/ofazvvwprvrwg2kntdn4qwaf7xs.png\"><\/p>\n<h3>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u0411\u0414 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 4 \u0442\u0430\u0431\u043b\u0438\u0446: \u0441\u0442\u0443\u0434\u0438\u0438, \u0437\u0430\u043b\u044b, 2 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  \u0412 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0435\u0441\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043f\u0435\u0440\u0438\u043e\u0434\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441 \u043d\u043e\u0432\u044b\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f. \u0417\u0430\u0442\u0438\u0440\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e (\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0434\u043d\u044f\/\u0447\u0430\u0441\u0430, \u043a\u043e\u0433\u0434\u0430 \u0431\u044b\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u0431\u0440\u043e\u043d\u044c). \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043e\u0434\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0434\u043b\u044f \u0441\u044b\u0440\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430, \u0432\u0442\u043e\u0440\u0430\u044f \u2014 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"> def create_tables(conn, table = 'all'):     cur = conn.cursor()          if (table == 'all') or (table == 'uStudios'):         cur.execute('''             CREATE TABLE IF NOT EXISTS uStudios             (studio_id INT PRIMARY KEY UNIQUE,             name TEXT UNIQUE,             metro TEXT,             address TEXT,             phone TEXT,             email TEXT,             established_date DATE)             ''')         print('Table uStudios is created.')      if (table == 'all') or (table == 'uHalls'):         cur.execute('''             CREATE TABLE IF NOT EXISTS uHalls             (hall_id INT PRIMARY KEY UNIQUE,             studio_id INT,             name TEXT,             is_hall INT,             square FLOAT,             ceiling FLOAT,             open_date DATE)             ''')         print('Table uHalls is created.')      if (table == 'all') or (table == 'uBooking_parsing'):         cur.execute('''             CREATE TABLE IF NOT EXISTS uBooking_parsing             (hall_id INT,             date DATE,             hour INT,             is_working_hour INT,             min_hours INT,             price INTEGER,             is_booked INT,             duration INT,             parsing_date DATE)             ''')         print ('Table uBooking_parsing is created.')      if (table == 'all') or (table == 'uBooking'):         cur.execute('''             CREATE TABLE IF NOT EXISTS uBooking             (hall_id INT,             date DATE,             hour INT,             is_working_hour INT,             min_hours INT,             price INTEGER,             is_booked INT,             duration INT,             parsing_date DATE)             ''')         print ('Table uBooking is created.') <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c table \u0437\u0430\u0434\u0430\u044e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0432\u0441\u0435.<\/p>\n<p>  \u0412 \u043f\u043e\u043b\u044f\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432\u0438\u0434\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0430\u0440\u0441\u0438\u043b\u0438 (\u0434\u0430\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0442\u0443\u0434\u0438\u0438, \u0434\u0430\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0437\u0430\u043b\u0430). \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u043f\u043e\u043b\u0435\u0439 \u043e\u043f\u0438\u0448\u0443 \u043f\u043e\u0437\u0436\u0435.<\/p>\n<h3>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c 6 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445:  <\/p>\n<ol>\n<li>\u0417\u0430\u043f\u0438\u0441\u044c \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445;<\/li>\n<li>\u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445;<\/li>\n<li>\u0417\u0430\u043f\u0438\u0441\u044c \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043b\u043e\u0432;<\/li>\n<li>\u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043b\u043e\u0432;<\/li>\n<li>\u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e;<\/li>\n<li>\u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<\/li>\n<\/ol>\n<h4>1. \u0417\u0430\u043f\u0438\u0441\u044c \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0432\u0438\u0434\u0435 DataFrame. \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e, \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u044f \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0446\u0438\u043a\u043b\u043e\u043c. \u041f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 python \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 &quot;?&quot; \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u0441\u043b\u0435.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def studios_to_db(conn, studio_list):      cur = conn.cursor()     for i in studio_list.index:         cur.execute('INSERT OR IGNORE INTO uStudios (studio_id, name, metro, address, phone, email) VALUES(?, ?, ?, ?, ?, ?)',                    (i,                    studio_list.loc[i, 'name'],                    studio_list.loc[i, 'metro'],                    studio_list.loc[i, 'address'],                    studio_list.loc[i, 'phone'],                    studio_list.loc[i, 'email']))<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h4>2. \u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u041d\u0430 \u0432\u0445\u043e\u0434 \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c select-\u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 DataFrame. \u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0434\u0430\u0442\u0443 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u0442\u044b.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def db_to_studios(conn):     cur = conn.cursor()     cur.execute('SELECT * FROM uStudios')     studios = pd.DataFrame(cur.fetchall()                            , columns=['studio_id', 'name', 'metro', 'address', 'phone', 'email', 'established_date']                           ).set_index('studio_id')     studios['established_date'] = pd.to_datetime(studios['established_date'])     return studios<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h4>3. \u0417\u0430\u043f\u0438\u0441\u044c \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043b\u043e\u0432 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439: \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0437\u0430\u043b\u043e\u0432, \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0430\u0437\u0443.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043b\u043e\u0432 \u0432 \u0411\u0414<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def halls_to_db(conn, halls):      cur = conn.cursor()     for i in halls.index:         cur.execute('INSERT OR IGNORE INTO uHalls (hall_id, studio_id, name, is_hall, square, ceiling) VALUES(?, ?, ?, ?, ?, ?)',                    (i,                    halls.loc[i, 'studio_id'],                    halls.loc[i, 'name'],                    halls.loc[i, 'is_hall'],                    halls.loc[i, 'square'],                    halls.loc[i, 'ceiling']))<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h4>4. \u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043b\u043e\u0432 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439: \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, select-\u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442, \u0437\u0430\u043f\u0438\u0441\u044c \u0432 DataFrame, \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0434\u0430\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0437\u0430\u043b\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u0442\u044b.<br \/>  \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435: id \u0441\u0442\u0443\u0434\u0438\u0438 \u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0437\u0430\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438\u0441\u044c \u0432 \u0431\u0430\u0439\u0442\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439:   <\/p>\n<pre><code class=\"python\">int.from_bytes(\u0447\u0438\u0441\u043b\u043e, 'little')<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043b\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def db_to_halls(conn):     cur = conn.cursor()     cur.execute('SELECT * FROM uHalls')     halls = pd.DataFrame(cur.fetchall(), columns=['hall_id', 'studio_id', 'name', 'is_hall', 'square', 'ceiling', 'open_date']).set_index('hall_id')     for i in halls.index:         halls.loc[i, 'studio_id'] = int.from_bytes(halls.loc[i, 'studio_id'], 'little')         halls.loc[i, 'is_hall'] = int.from_bytes(halls.loc[i, 'is_hall'], 'little')     halls['open_date'] = pd.to_datetime(halls['open_date'])     return halls<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h4>5. \u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u0412 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0411\u0414 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 parsing, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0438\u0437 \u043a\u0430\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e: 0 \u2014 \u0438\u0437 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e), 1 \u2014 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430. \u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c select-\u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 DataFrame. \u0414\u0430\u0442\u044b \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u0442, \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u0447\u0438\u0441\u0435\u043b.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def db_to_booking(conn, parsing = 0):     cur = conn.cursor()     if parsing == 1:         cur.execute('SELECT * FROM uBooking_parsing')     else:         cur.execute('SELECT * FROM uBooking')     booking = pd.DataFrame(cur.fetchall(), columns=['hall_id',                                                       'date', 'hour',                                                       'is_working_hour',                                                       'min_hours',                                                       'price',                                                       'is_booked',                                                       'duration',                                                       'parsing_date'])     booking['hall_id'] = [int.from_bytes(x, 'little') if not isinstance(x, int) else x for x in booking['hall_id']]     booking['is_booked'] = [int.from_bytes(x, 'little') if not isinstance(x, int) else x for x in booking['is_booked']]     booking['date'] = pd.DataFrame(booking['date'])     booking['parsing_date'] = pd.DataFrame(booking['parsing_date'])          return booking<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h4>6. \u0417\u0430\u043f\u0438\u0441\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  \u0421\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0411\u0414, \u0442.\u043a. \u043e\u043d\u0430 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442 \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e. \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a id \u0437\u0430\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0434\u0430\u0442\u0443 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445,   <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0437\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u0438\u0437 \u0431\u0430\u0437\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0434\u0430\u0442\u0443 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 id \u0437\u0430\u043b\u0430:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">parsing_date = db_to_booking(conn, parsing = 1).groupby('hall_id').agg(np.max)['parsing_date']<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 id \u0437\u0430\u043b\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0438\u043a\u043b\u0430.<\/p>\n<p>  \u0412 \u043a\u0430\u0436\u0434\u043e\u043c id \u0437\u0430\u043b\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u043b\u043e\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">        try:             last_day_str = parsing_date[id]             last_day = datetime.datetime.strptime(last_day_str, '%Y-%m-%d')             delta_days = (datetime.datetime.now() - last_day).days             weeks_ago = delta_days \/\/ 7         except:             last_day_str = '2010-01-01'             last_day = datetime.datetime.strptime(last_day_str, '%Y-%m-%d')             weeks_ago = 500<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0415\u0441\u043b\u0438 id \u0437\u0430\u043b\u0430 \u0435\u0441\u0442\u044c \u0432 \u0431\u0430\u0437\u0435, \u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u043f\u0430\u0440\u0441\u0438\u043c 500 \u043d\u0435\u0434\u0435\u043b\u044c \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0435 \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 2 \u043c\u0435\u0441\u044f\u0446\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u0431\u0440\u043e\u043d\u0435\u0439 (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/504900\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>).<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">        d = get_past_booking(id, weeks_ago = weeks_ago)                 d.update(get_future_booking(id))         book = hall_booking(d)<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0430\u0440\u0441\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0434\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0442\u043e\u043c \u0438\u0437 \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e (\u0434\u043e 2 \u043c\u0435\u0441\u044f\u0446\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0435 \u0431\u044b\u043b\u043e) \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 json \u0432 DataFrame.<\/p>\n<p>  \u0417\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0437\u0430\u043b\u0430 \u0432 \u0431\u0430\u0437\u0443 \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def booking_to_db(conn, halls_id):     cur = conn.cursor()     cur_date = pd.Timestamp(datetime.date.today())     parsing_date = db_to_booking(conn, parsing = 1).groupby('hall_id').agg(np.max)['parsing_date']          for id in halls_id:                  #download last parsing_date from DataBase         try:             last_day_str = parsing_date[id]             last_day = datetime.datetime.strptime(last_day_str, '%Y-%m-%d')             delta_days = (datetime.datetime.now() - last_day).days             weeks_ago = delta_days \/\/ 7         except:             last_day_str = '2010-01-01'             last_day = datetime.datetime.strptime(last_day_str, '%Y-%m-%d')             weeks_ago = 500                  d = get_past_booking(id, weeks_ago = weeks_ago)                 d.update(get_future_booking(id))         book = hall_booking(d)         for i in list(range(len(book))):#book.index:             cur.execute('INSERT OR IGNORE INTO uBooking_parsing (hall_id, date, hour, is_working_hour, min_hours, price, is_booked, duration, parsing_date) VALUES(?,?,?,?,?,?,?,?,?)',                        (book.iloc[i]['hall_id'],                        book.iloc[i]['date'].date().isoformat(),                        book.iloc[i]['hour'],                        book.iloc[i]['is_working_hour'],                        book.iloc[i]['min_hours'],                        book.iloc[i]['price'],                        book.iloc[i]['is_booked'],                        book.iloc[i]['duration'],                        cur_date.date().isoformat()))         conn.commit()         print('hall_id ' + str(id) + ' added. ' + str(list(halls_id).index(id) + 1) + ' from ' + str(len(halls_id)))<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h3>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043d\u0435\u0439 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0442\u0443\u0434\u0438\u0438 \u0438 \u0437\u0430\u043b\u043e\u0432<\/h3>\n<p>  \u0414\u0430\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0437\u0430\u043b\u0430 \u2014 \u044d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0440\u0430\u043d\u043d\u044f\u044f \u0434\u0430\u0442\u0430 \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043b\u0430.<br \/>  \u0414\u0430\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0438 \u2014 \u044d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0440\u0430\u043d\u043d\u044f\u044f \u0434\u0430\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0437\u0430\u043b\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0443\u0434\u0438\u0438.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u044d\u0442\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438,   <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u0430\u043c\u044b\u0435 \u0440\u0430\u043d\u043d\u0438\u0435 \u0434\u0430\u0442\u044b \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043b\u0430 \u0438\u0437 \u0431\u0430\u0437\u044b<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">halls = db_to_booking(conn).groupby('hall_id').agg(min)['date']<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0417\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0437\u0430\u043b\u043e\u0432:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    for i in list(range(len(halls))):         cur.execute('''UPDATE uHalls SET open_date = '{1}' WHERE hall_id = {0}'''                     .format(halls.index[i], str(halls.iloc[i])))<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e: \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0434\u0430\u0442\u0430\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0437\u0430\u043b\u043e\u0432 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0434\u0430\u0442\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0443\u0434\u0438\u0438, \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u0442\u0443 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0438.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def update_open_dates(conn):          cur = conn.cursor()          #update open date in uHalls     halls = db_to_booking(conn).groupby('hall_id').agg(min)['date']          for i in list(range(len(halls))):         cur.execute('''UPDATE uHalls SET open_date = '{1}' WHERE hall_id = {0}'''                     .format(halls.index[i], str(halls.iloc[i])))      #update open date in uStudios     studios = db_to_halls(conn)     studios['open_date'] = pd.to_datetime(studios['open_date'])     studios = studios.groupby('studio_id').agg(min)['open_date']     for i in list(range(len(studios))):         cur.execute('''UPDATE uStudios SET established_date = '{1}' WHERE  studio_id = {0}'''                     .format(studios.index[i], str(studios.iloc[i])))          conn.commit()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h3>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430<\/h3>\n<p>  \u0412\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0432 \u044d\u0442\u043e\u0439 \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/504900\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439<\/a> \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043c\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435. \u0415\u0451 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0435, \u0442\u0430\u043a \u0438 \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">def update_parsing(directory = '.\/\/', is_manual = 0):          start_time = time.time()          #is DataBase exists?     if not os.path.exists(directory + 'photostudios_moscow1.sqlite'):         if is_manual == 1:             print('Data base is not exists. Do you want to create DataBase (y\/n)? ')             answer = input().lower()         else:              answer == 'y'                  if answer == 'y':             conn = sqlite3.connect(directory + 'photostudios_moscow1.sqlite')             conn.close()             print('DataBase is created')         elif answer != 'n':             print('Error in input!')             return list()          print('DataBase is exists')     print(&quot;--- %s seconds ---&quot; % (time.time() - start_time))     start_time = time.time()              #connect to DataBase     conn = sqlite3.connect(directory + 'photostudios_moscow1.sqlite')     cur = conn.cursor()             #has DataBase 4 tables?     tables = [x[0] for x in list(cur.execute('SELECT name FROM sqlite_master WHERE type=&quot;table&quot;'))]     if not ('uStudios' in tables) &amp; ('uHalls' in tables) &amp; ('uBooking_parsing' in tables) &amp; ('uBooking' in tables):         if is_manual == 1:             print('Do you want to create missing tables (y\/n)? ')             answer = input().lower()         else:             answer = 'y'                  if anwer == 'y':             if not ('uStudios' in tables):                 create_tables(conn, table = 'uStudios')              if not ('uHalls' in tables):                 create_tables(conn, table = 'uHalls')              if not ('uBooking_parsing' in tables):                 create_tables(conn, table = 'uBooking_parsing')              if not ('uBooking' in tables):                 create_tables(conn, table = 'uBooking')          elif answer != 'n':             print('Error in input!')             return list()      conn.commit()     print(str(tables) + ' are exist in DataBase')     print(&quot;--- %s seconds ---&quot; % (time.time() - start_time))     start_time = time.time()          #update uStudios     studios = studio_list()     new_studios = studios[[x not in list(db_to_studios(conn).index) for x in list(studios.index)]]     if len(new_studios) &gt; 0:         print(str(len(new_studios)) + ' new studios detected: \\n' + str(list(new_studios['name'])))         studios_to_db(conn, new_studios)          conn.commit()     print('Studio list update was successful')     print(&quot;--- %s seconds ---&quot; % (time.time() - start_time))     start_time = time.time()          #update uHalls     halls = hall_list(list(studios.index)).sort_index()     new_halls = halls[[x not in list(db_to_halls(conn).index) for x in list(halls.index)]]     if len(new_halls) &gt; 0:         halls_to_db(conn, new_halls)          conn.commit()     print('Halls list update was successful')     print(&quot;--- %s seconds ---&quot; % (time.time() - start_time))     start_time = time.time()              #update uBooking_parsing     booking_to_db(conn, halls.index)             conn.commit()     print('Booking_parsing update was successful')     print(&quot;--- %s seconds ---&quot; % (time.time() - start_time))     start_time = time.time()          #update uBooking from uBooking_parsing     cur.execute('DELETE FROM uBooking')     cur.execute('''         insert into uBooking (hall_id, date, hour, is_working_hour, min_hours, price, is_booked, duration, parsing_date)          select hall_id, date, hour, is_working_hour, min_hours, price, is_booked, duration, parsing_date         from         (             select *, row_number() over(partition by hall_id, date, hour order by parsing_date desc) rn              from uBooking_parsing         ) t         where rn = 1     ''')     conn.commit()     print('Booking update was successful')     print(&quot;--- %s seconds ---&quot; % (time.time() - start_time))     start_time = time.time()          update_open_dates(conn)     conn.commit()     print('Open date update was successful')     print(&quot;--- %s seconds ---&quot; % (time.time() - start_time))          conn.close() <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p>  \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u0430\u0434\u0440\u0435\u0441 \u043f\u0430\u043f\u043a\u0438, \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0440\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u043a\u0443\u0434\u0430 \u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0435\u0440\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u0441 python-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432), \u0438 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 is_manual, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u00ab1\u00bb \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0441\u0442\u044c \u043b\u0438 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0441\u043e\u0437\u0434\u0430\u0451\u043c:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    if not os.path.exists(directory + 'photostudios_moscow1.sqlite'):         if is_manual == 1:             print('Data base is not exists. Do you want to create DataBase (y\/n)? ')             answer = input().lower()         else:              answer == 'y'                  if answer == 'y':             conn = sqlite3.connect(directory + 'photostudios_moscow1.sqlite')             conn.close()             print('DataBase is created')         elif answer != 'n':             print('Error in input!')             return list()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c\u0441\u044f \u043a \u0411\u0414 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0443\u0440\u0441\u043e\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    conn = sqlite3.connect(directory + 'photostudios_moscow1.sqlite')     cur = conn.cursor() <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u0441\u0435 \u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u044b. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    tables = [x[0] for x in list(cur.execute('SELECT name FROM sqlite_master WHERE type=&quot;table&quot;'))]     if not ('uStudios' in tables) &amp; ('uHalls' in tables) &amp; ('uBooking_parsing' in tables) &amp; ('uBooking' in tables):         if is_manual == 1:             print('Do you want to create missing tables (y\/n)? ')             answer = input().lower()         else:             answer = 'y'                  if anwer == 'y':             if not ('uStudios' in tables):                 create_tables(conn, table = 'uStudios')              if not ('uHalls' in tables):                 create_tables(conn, table = 'uHalls')              if not ('uBooking_parsing' in tables):                 create_tables(conn, table = 'uBooking_parsing')              if not ('uBooking' in tables):                 create_tables(conn, table = 'uBooking')          elif answer != 'n':             print('Error in input!')             return list()      conn.commit()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439. \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0411\u0414 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u043e\u0432\u044b\u0445 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    studios = studio_list()     new_studios = studios[[x not in list(db_to_studios(conn).index) for x in list(studios.index)]]     if len(new_studios) &gt; 0:         print(str(len(new_studios)) + ' new studios detected: \\n' + str(list(new_studios['name'])))         studios_to_db(conn, new_studios)<\/code><\/pre>\n<p>   conn.commit()  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043b\u043e\u0432 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    halls = hall_list(list(studios.index)).sort_index()     new_halls = halls[[x not in list(db_to_halls(conn).index) for x in list(halls.index)]]     if len(new_halls) &gt; 0:         halls_to_db(conn, new_halls)          conn.commit()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 uBooking_parsing. \u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0442.\u043a. \u0432\u0441\u044e \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0432 \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 booking_to_db<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    booking_to_db(conn, halls.index)             conn.commit()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 uBooking. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u0440\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e uBooking \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b uBooking_parsing \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438 (\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043b\u0430, \u0434\u0430\u0442\u044b \u0438 \u0447\u0430\u0441\u0430 \u0431\u0440\u043e\u043d\u0438) \u0434\u0430\u0442\u0430\u043c\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    cur.execute('DELETE FROM uBooking')     cur.execute('''         insert into uBooking (hall_id, date, hour, is_working_hour, min_hours, price, is_booked, duration, parsing_date)          select hall_id, date, hour, is_working_hour, min_hours, price, is_booked, duration, parsing_date         from         (             select *, row_number() over(partition by hall_id, date, hour order by parsing_date desc) rn              from uBooking_parsing         ) t         where rn = 1     ''')     conn.commit()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u0442\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u0442\u0443\u0434\u0438\u0439 \u0438 \u0437\u0430\u043b\u043e\u0432:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    update_open_dates(conn)     conn.commit()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0418 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0431\u0430\u0437\u0443<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">    conn.close()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0411\u0414 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e!<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0418\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u0441\u0438\u043d\u0433\/\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">update_parsing()<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/504900\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439<\/a> \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043f\u043e \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u044f\u043c. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u043c\u043e\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0432 <a href=\"https:\/\/github.com\/dmitry-data-science\/studios\" rel=\"nofollow\">github<\/a>.<\/div>\n<p> \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\/post\/512208\/\"> https:\/\/habr.com\/ru\/post\/512208\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/512208\/\">\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/504900\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0440\u044b\u043d\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430: \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u043e\u0442\u043e\u0441\u0442\u0443\u0434\u0438\u0439, \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u043b\u043e\u0432, \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0437\u0430\u043b\u0430 \u0434\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0431\u0440\u043e\u043d\u0438.<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043a\u044d\u0448\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e:   <\/p>\n<ul>\n<li>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 SQLite \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445; <\/li>\n<li>\u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c Python; <\/li>\n<li>\u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 DataFrame; <\/li>\n<li>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0411\u0414. <\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tv\/_n\/cp\/tv_ncpotzlttmr8op_izcdawn58.jpeg\">  <\/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-307787","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307787","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=307787"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307787\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=307787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=307787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=307787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}