{"id":296046,"date":"2019-12-19T03:00:10","date_gmt":"2019-12-19T03:00:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296046"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296046","title":{"rendered":"Python, \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0411\u0414"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/481084\/\">\n<h1>\u0411\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h1>\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0437\u0434\u0435\u0441\u044c \u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b, \u0438 \u0442.\u0434.; \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c python \u0438 \u0435\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 sqlite3.<\/p>\n<p><b>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212;<\/b> \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e \u0441\u0445\u0435\u043c\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<p>\u0422\u0430\u043a \u043d\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u042f\u043d\u0434\u0435\u043a\u0441, \u043d\u043e \u0435\u0441\u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043d\u0435 \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u044f\u0441\u044c \u0432\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f, \u0442\u043e:<\/p>\n<p><b>\u0411\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u0411\u0414) &#8212;<\/b> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p> \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0439\u0442\u0438 \u0438 \u0432\u0437\u044f\u0442\u044c \u043a\u043d\u0438\u0433\u0443 \u00ab\u0412\u043e\u0439\u043d\u0430 \u0438 \u043c\u0438\u0440\u00bb, \u0437\u043d\u0430\u044f \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0440\u043e\u043c\u0430\u043d\u043e\u0432, \u043d\u0430 \u0431\u0443\u043a\u0432\u0443 \u00ab\u0412\u00bb, \u0442\u0430\u043a \u0438 \u0438\u0437 \u0411\u0414 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0443, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0430\u043d\u0440\u0443.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<blockquote><p>\u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p><\/blockquote>\n<p>\u0418 \u0447\u0442\u043e \u0431\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043a\u043e\u0435-\u0447\u0442\u043e \u0443\u0437\u043d\u0430\u0442\u044c.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h1>\u041a\u0430\u043a \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h1>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0411\u0414 \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430:<\/p>\n<ul>\n<li>\u0420\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0435<\/li>\n<li>\u0421\u0435\u0442\u0435\u0432\u044b\u0435<\/li>\n<li>\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0435<\/li>\n<\/ul>\n<h5>\u0421\u0435\u0442\u0435\u0432\u044b\u0435 \u0438 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0411\u0414:<\/h5>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0411\u0414 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0433\u0440\u0430\u0444\u044b \u0438 \u0445\u0440\u0430\u043d\u044f\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u043d\u0438\u0445 \u0436\u0435.<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0418\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u2014 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0439 \u0433\u0440\u0430\u0444<\/li>\n<li>\u0421\u0435\u0442\u0435\u0432\u044b\u0435 \u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u0433\u0440\u0430\u0444<\/li>\n<\/ul>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0411\u0414 \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0411\u0414.<\/p>\n<h5>\u0420\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h5>\n<p><b>\u0420\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0411\u0414 &#8212;<\/b> \u0411\u0414, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Exel.<\/p>\n<\/p>\n<p><b>SQL &#8212;<\/b> \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0411\u0414, \u0438 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u0439 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f, \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gh\/5g\/fw\/gh5gfwrtvxcfoc4jdbhyhsi914s.png\"><\/p>\n<p>\u042f \u0434\u0443\u043c\u0430\u044e \u0447\u0442\u043e, \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u043c\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u043b\u0438, \u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h1>\u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u043d\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445?<\/h1>\n<p>\u0417\u0430 \u0432\u0441\u044e \u0436\u0438\u0437\u043d\u044c, \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u043a\u043e\u043f\u0438\u043b\u0430 \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0430 \u0411\u0414, \u043a\u0430\u043a \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442, \u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c <b>(\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435)<\/b>. \u0418 \u0411\u0414 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0441\u0435\u0439 \u044d\u0442\u043e\u0439 \u043a\u0443\u0447\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0451 \u0442\u0443\u0434\u0430, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0442.\u0434.;<\/p>\n<h1>\u0418\u0437 \u0442\u0435\u043e\u0440\u0438\u0438 \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443<\/h1>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043f\u043e\u0439\u0434\u0451\u043c \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443, \u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c \u043a\u043e\u0435-\u0447\u0442\u043e. \u0421\u0432\u0435\u0440\u0445\u0443 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<p>  <\/p>\n<blockquote><p><b>SQL &#8212;<\/b> \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0411\u0414, \u0438 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u0439 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f, \u0432 \u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. <\/p><\/blockquote>\n<p>  <\/p>\n<p>\u0418 \u043a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u044d\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u043e.<br \/>  <b> SQL &#8212;<\/b> \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (structured query language). \u0413\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u044d\u0442\u043e \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0411\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0432 \u043d\u0438\u0445 \u0438 \u0442.\u0434.<\/p>\n<p>\u041c\u043e\u0439 \u043a\u043e\u0441\u044f\u043a \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438, \u0438\u0434\u0451\u043c \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443!<\/p>\n<p>  <cut><\/cut><\/p>\n<h1>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 sqlite3<\/h1>\n<p>\u0414\u0430, \u044d\u0442\u043e \u0441\u043c\u0435\u0448\u043d\u043e, \u043d\u043e \u043c\u0430\u043b\u043e \u043b\u0438 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f<\/p>\n<p>  <\/p>\n<p>\u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0432\u0435\u0434\u044c \u044d\u0442\u043e \u0434\u0430\u0432\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0437\u0430 \u043c\u0435\u043d\u044f, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0442\u043e \u043f\u0440\u043e\u0441\u044c\u0431\u0430 \u0438\u0434\u0442\u0438 \u0432\u043e\u0442 <a href=\"http:\/\/unetway.com\/tutorial\/sqlite-install\/\" rel=\"nofollow\">\u0441\u044e\u0434\u0430.<\/a><\/p>\n<h1>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u0411\u0414<\/h1>\n<pre><code class=\"python\">import sqlite3 as sql  con = sql.connect('test.db') with con:     cur = con.cursor()     cur.execute(\"CREATE TABLE IF NOT EXISTS `test` (id INTEGER)\")     con.commit() <\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043c\u043f\u043e\u0440\u0442, \u043f\u043e\u0442\u043e\u043c \u00abcon =\u00bb.<br \/>  \u041e\u0431\u044a\u044f\u0441\u043d\u044f\u044e, <i>sql.connect(\u00abtest.db\u00bb)<\/i> \u2014 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u00abtest.db\u00bb, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0432\u043f\u0435\u0440\u0432\u044b\u0435. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c .db<\/p>\n<p>  <\/p>\n<p>cur = con.cursor \u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u0411\u0414, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0435 \u0432\u0430\u0436\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>cur.execute(&#8230;) \u2014 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0442\u0435\u0441\u0442 \u0438 \u0432\u0441\u0435\u0433\u043e 1 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439 id, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u2014 \u0447\u0438\u0441\u043b\u0430<\/p>\n<p>  <\/p>\n<p>commit() \u2014 \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0411\u0414<\/p>\n<\/p>\n<p>\u0410 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0438\u043c\u044f \u0438 \u0444\u0430\u043c\u0438\u043b\u0438\u044e, \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0411\u0414, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e \u0432\u044b\u0431\u043e\u0440\u0443 \u0446\u0438\u0444\u0440 \u043b\u0438\u0431\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442, \u043b\u0438\u0431\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043d\u043e\u0432\u0430.<\/p>\n<pre><code class=\"python\">import sqlite3 as sql  print(\"1 - \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\\n2 - \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\") choice = int(input(\"&gt; \")) con = sql.connect('test.db') with con:     cur = con.cursor()     cur.execute(\"CREATE TABLE IF NOT EXISTS `test` (`name` STRING, `surname` STRING)\")      if choice == 1:         name = input(\"Name\\n&gt; \")         surname = input(\"Surname\\n&gt; \")         cur.execute(f\"INSERT INTO `test` VALUES ('{name}', '{surname}')\")     elif choice == 2:         cur.execute(\"SELECT * FROM `test`\")         rows = cur.fetchall()         for row in rows:             print(row[0], row[1])     else:         print(\"\u0412\u044b \u043e\u0448\u0438\u0431\u043b\u0438\u0441\u044c\")      con.commit()     cur.close()  <\/code><\/pre>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c.<\/p>\n<p>  <\/p>\n<p>cur.execute(\u00abINS&#8230;\u00bb) \u2014 \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<p>  <\/p>\n<p>cur.execute(\u00abSeL&#8230;\u00bb) \u2014 \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043c \u043e\u0442\u0434\u0430\u0451\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432, \u0442\u043e \u043c\u044b \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0435\u0449\u0451 \u0438 \u0438\u0437 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0440\u0451\u043c.<\/p>\n<p>  <\/p>\n<p>\u00abSELECT\u00bb, \u00abINSERT\u00bb, \u00abDROP\u00bb \u0438 \u0442.\u0434. \u2014 \u044d\u0442\u043e \u0432\u0441\u0451 SQL.<\/p>\n<p>  <\/p>\n<p>cur.fetchall() \u2014 \u044d\u0442\u043e \u0447\u0442\u043e \u0431\u044b \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u043b\u043e \u0438\u0437 \u0411\u0414.<\/p>\n<h1>\u0412\u044b\u0432\u043e\u0434<\/h1>\n<p>  <\/p>\n<p>\u0411\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u0432\u0430\u0436\u043d\u0430\u044f \u0438 \u043e\u0447\u0435\u043d\u044c \u043d\u0443\u0436\u043d\u0430\u044f \u0432\u0435\u0449\u044c. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b\u0438 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0451 \u043c\u0430\u043b\u0443\u044e \u0447\u0430\u0441\u0442\u044c, \u0447\u0442\u043e \u0430\u0436 \u0441\u043c\u0435\u0448\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0432\u0441\u0451\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0431\u043b\u0430\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043c\u043d\u043e\u0433\u043e. \u0423\u0434\u0430\u0447\u0438!<\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <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\/post\/481084\/\"> https:\/\/habr.com\/ru\/post\/481084\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/481084\/\">\n<h1>\u0411\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h1>\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0437\u0434\u0435\u0441\u044c \u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b, \u0438 \u0442.\u0434.; \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c python \u0438 \u0435\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 sqlite3.<\/p>\n<p><b>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212;<\/b> \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e \u0441\u0445\u0435\u043c\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<p>\u0422\u0430\u043a \u043d\u0430\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u042f\u043d\u0434\u0435\u043a\u0441, \u043d\u043e \u0435\u0441\u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043d\u0435 \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u044f\u0441\u044c \u0432\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f, \u0442\u043e:<\/p>\n<p><b>\u0411\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u0411\u0414) &#8212;<\/b> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0445\u0440\u0430\u043d\u044f\u0449\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u043e\u043c \u0438\u043b\u0438 \u0438\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p> \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0439\u0442\u0438 \u0438 \u0432\u0437\u044f\u0442\u044c \u043a\u043d\u0438\u0433\u0443 \u00ab\u0412\u043e\u0439\u043d\u0430 \u0438 \u043c\u0438\u0440\u00bb, \u0437\u043d\u0430\u044f \u0447\u0442\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0436\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0440\u043e\u043c\u0430\u043d\u043e\u0432, \u043d\u0430 \u0431\u0443\u043a\u0432\u0443 \u00ab\u0412\u00bb, \u0442\u0430\u043a \u0438 \u0438\u0437 \u0411\u0414 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0443, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0430\u043d\u0440\u0443.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<blockquote><p>\u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p><\/blockquote>\n<p>\u0418 \u0447\u0442\u043e \u0431\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043a\u043e\u0435-\u0447\u0442\u043e \u0443\u0437\u043d\u0430\u0442\u044c.<\/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-296046","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296046","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=296046"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296046\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}