{"id":363509,"date":"2024-05-21T01:57:27","date_gmt":"2024-05-21T01:57:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=363509"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=363509","title":{"rendered":"<span>\u041f\u043e\u0431\u0435\u0434\u0430 \u043d\u0430\u0434 ORM \u043f\u0443\u0442\u0435\u043c \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0440\u0430\u0437\u0443 \u0445\u043e\u0447\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u0435\u043c\u0443, \u0430 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f Python, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 github \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 pip, \u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0443\u0434\u0438\u0442\u0441\u044f \u0432 \u043c\u043e\u0435\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0438\u0433\u0440\u0435 \u043a\u0430\u043a SQL \u0434\u0432\u0438\u0436\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b ORM \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0442\u044c \u0440\u0430\u0437 \u0438\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f. \u041e\u0431 \u044d\u0442\u043e\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 (<a href=\"https:\/\/habr.com\/ru\/articles\/458286\/\" rel=\"noopener noreferrer nofollow\">1<\/a>, <a href=\"https:\/\/habr.com\/ru\/companies\/karuna\/articles\/774478\/\" rel=\"noopener noreferrer nofollow\">2<\/a>, <a href=\"https:\/\/habr.com\/ru\/articles\/667078\/\" rel=\"noopener noreferrer nofollow\">3<\/a>, <a href=\"https:\/\/habr.com\/ru\/companies\/hexlet\/articles\/271117\/\" rel=\"noopener noreferrer nofollow\">4<\/a>), \u0442\u0430\u043a \u0438 \u0432 \u0437\u0430\u0440\u0443\u0431\u0435\u0436\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u0445 (<a href=\"https:\/\/martinfowler.com\/bliki\/OrmHate.html\" rel=\"noopener noreferrer nofollow\">1<\/a>, <a href=\"https:\/\/kurapov.ee\/eng\/tech\/ORM-is-harfmul-pattern\/\" rel=\"noopener noreferrer nofollow\">2<\/a>, <a href=\"https:\/\/news.ycombinator.com\/item?id=36497613\" rel=\"noopener noreferrer nofollow\">3<\/a>, <a href=\"https:\/\/news.ycombinator.com\/item?id=11609719\" rel=\"noopener noreferrer nofollow\">4<\/a>). \u042d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u043e\u0431\u0449\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Object%E2%80%93relational_impedance_mismatch\" rel=\"noopener noreferrer nofollow\">Object-relational impedance mismatch<\/a>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044e \u0441\u0435\u0431\u0435 \u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u043a &#171;\u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u043e\u0432&#187;.<\/p>\n<p>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e ORM \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0438\u0441\u0442\u044b\u0445 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u044b\u0440\u044b\u0445 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c <em>\u043e\u0447\u0435\u043d\u044c \u0442\u044f\u0436\u0435\u043b\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445<\/em>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0445\u0430\u0438\u0442\u044c ORM (<em>\u0434\u043e \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0431\u0435\u0437 \u043c\u0430\u043b\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u0430\u0434\u0435\u0441\u044f\u0442\u043a\u0430 \u043b\u0435\u0442<\/em>), \u043d\u043e \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 <em>\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e<\/em> \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u042f\u041f.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0443\u043b\u0430\u0442\u044b, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u043f\u0440\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<ol>\n<li>\n<p> \u041f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c SQL. \u0411\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Domain-specific_language\" rel=\"noopener noreferrer nofollow\">DSL<\/a>, \u0431\u0435\u0437 \u041e\u041e\u041f-\u043e\u0431\u0435\u0440\u0442\u043e\u043a, \u0431\u0435\u0437 SQL-\u0431\u0438\u043b\u0434\u0435\u0440\u043e\u0432. <\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0447\u0435\u043c\u0443?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, SQL &#8212; \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0435\u043e\u0431\u044b\u0447\u0435\u043d \u043e\u043d \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0410 \u0432\u0441\u0435 RDBMS, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0433\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e\u0442 (postgresql, mysql, mssql, sqlite, etc.), \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0443 \u044f\u0437\u044b\u043a\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u043c\u0443 \u0438\u0445 \u0431\u0438\u0437\u043d\u0435\u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c. \u0418 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u044d\u0442\u0438 \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u044b \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b \u0441\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 SQL. <\/p>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 (\u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u0441\u0435) ORM \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043e\u0431\u0449\u0438\u0439 \u043c\u0435\u0436\u0434\u0438\u0430\u043b\u0435\u043a\u0442\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 SQL \u043a\u043e\u0434\u0430. \u042d\u0442\u043e <em>\u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e <\/em>\u0440\u0435\u0448\u0430\u0435\u0442<em> <\/em>\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u044d\u0442\u0438\u043c \u0437\u0430\u043c\u044b\u043a\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 ORM \u043e\u0431\u0449\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432 \u0443\u0449\u0435\u0440\u0431 \u0447\u0430\u0441\u0442\u043d\u044b\u043c \u0441\u043b\u0443\u0447\u0430\u044f\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 RDBMS. <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 ORM \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0430 SQL \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. \u0421\u0447\u0438\u0442\u0430\u044e \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438 \u0440\u0435\u0434\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0447\u0438\u0441\u0442\u043e\u0433\u043e SQL \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0430 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044f\u043c \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 ORM \u0438 SQL-builder\u043e\u0432.<\/p>\n<\/div>\n<\/details>\n<ol start=\"2\">\n<li>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0435\u043c \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8212; \u044d\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430. <\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 f-string. <strong>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 <u>SQL \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0439<\/u>: \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0442\u0434\u0430\u0435\u043c \u043d\u0430 \u043e\u0442\u043a\u0443\u043f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>. <\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8212; \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0440\u043e\u043a\u0430, \u043a\u043e\u0440\u0442\u0435\u0436 (row) \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>User<\/code> \u0438 <code>Post<\/code>. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c <code>INNER JOIN<\/code> \u043f\u043e <code>user_id<\/code> \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>Post<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u043d\u0438\u0435\u043c <code>UserPost<\/code>. <\/p>\n<\/div>\n<\/details>\n<ol start=\"6\">\n<li>\n<p>\u0423 \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0438 <strong>\u044f\u0432\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/strong> <u>\u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/u>. <em>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043b\u0438\u043d\u0442\u0435\u0440 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0430 \u043d\u0430\u0448\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043e\u0433\u0430\u0442\u044c \u043d\u0430\u043c \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0435<\/em>.<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0443\u043d\u043a\u0442\u044b 5 \u0438 6 \u0432\u044b\u043d\u0443\u0436\u0434\u0430\u044e\u0442 \u043d\u0430\u0441 \u043b\u0438\u0431\u043e <em>\u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u044f\u0432\u043d\u043e \u0432 \u043a\u043e\u0434\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e<\/em>, \u043b\u0438\u0431\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 <em>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438<\/em>. <strong>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u0443\u0442\u044c \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0445\u0435\u043c\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>. <\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b, \u043d\u043e \u0435\u0441\u0442\u044c \u0432 ORM:<\/p>\n<ol>\n<li>\n<p><strong>\u0422\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 SQL \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u044b<\/strong>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, <a href=\"https:\/\/github.com\/tobymao\/sqlglot\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442 \u043a\u043e\u0434 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e SQL \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439<\/a>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438<\/strong>. ORM \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u044a\u0435\u043a\u0442 <code>sqlalchemy.orm.Session<\/code>). \u041c\u043e\u044f \u0436\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438 \u043f\u0443\u0441\u0442\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440.<\/p>\n<\/li>\n<\/ol>\n<h2>querky<\/h2>\n<p>\u0422\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u043c\u043e\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0437\u0432\u0430\u043b <strong>querky <\/strong>(<a href=\"https:\/\/github.com\/racinette\/querky\" rel=\"noopener noreferrer nofollow\">github<\/a>, <a href=\"https:\/\/pypi.org\/project\/querky\/\" rel=\"noopener noreferrer nofollow\">pypi<\/a>). \u0421\u0430\u043c\u043e \u0441\u043b\u043e\u0432\u043e &#8212; \u044d\u0442\u043e \u0441\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0445 \u0441\u043b\u043e\u0432 <em>query<\/em> (&#171;\u0437\u0430\u043f\u0440\u043e\u0441&#187;) \u0438 \u0441\u043e\u0437\u0432\u0443\u0447\u043d\u043e\u0433\u043e <em>quirky<\/em> (&#171;\u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439&#187;, &#171;\u043f\u0440\u0438\u0447\u0443\u0434\u043b\u0438\u0432\u044b\u0439&#187;).<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 <code>pip<\/code> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>pip install querky<\/code><\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/racinette\/querky_showcase\" rel=\"noopener noreferrer nofollow\">\u0441\u043a\u0435\u043b\u0435\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438 \u043f\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0432 \u0440\u0443\u043a\u0430\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438. \u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 <a href=\"https:\/\/github.com\/racinette\/querky\/blob\/main\/README.md\" rel=\"noopener noreferrer nofollow\">README<\/a> \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0412\u00a0\u0441\u0442\u0430\u0442\u044c\u0435\u00a0\u0436\u0435 \u044f \u0445\u043e\u0447\u0443 \u0432\u00a0\u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u00a0\u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c <a href=\"https:\/\/github.com\/racinette\/querky#how-it-works\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u0447\u0435\u0442.<\/a><\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u0448\u0438\u0440\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0430\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0415\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0434\u0435\u0442\u0430\u043b\u044f\u043c, \u0442\u043e \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0443. <\/p>\n<p>\u041c\u043e\u0433\u0443 \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430, \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 Python \u043c\u043e\u0434\u0443\u043b\u0438. \u041e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.python.org\/3\/library\/inspect.html\" rel=\"noopener noreferrer nofollow\">inspect<\/a>, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u044b\u043c \u044d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0442\u0435\u043c\u043f\u043b\u0435\u0439\u0442\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<\/div>\n<\/details>\n<p><em>\u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u044f \u043e\u0431\u044f\u0437\u0430\u043d \u043e\u0433\u043e\u0440\u0447\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u043e\u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439<\/em>, \u043e\u0442\u043c\u0435\u0442\u0438\u0432, \u0447\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 <a href=\"https:\/\/github.com\/MagicStack\/asyncpg\" rel=\"noopener noreferrer nofollow\">asynpg<\/a>. <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 PostgreSQL Python \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432: <a href=\"https:\/\/github.com\/psycopg\/psycopg2\" rel=\"noopener noreferrer nofollow\">psycopg2<\/a>, <a href=\"https:\/\/github.com\/psycopg\/psycopg\" rel=\"noopener noreferrer nofollow\">psycopg<\/a> (aka <em>psycopg3<\/em>) \u0438 <a href=\"https:\/\/github.com\/aio-libs\/aiopg\" rel=\"noopener noreferrer nofollow\">aiopg<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c type-inference \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 RDBMS &#8212; \u043e\u0431 \u044d\u0442\u043e\u043c \u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u0440\u0435\u043a\u0430\u044e\u0441\u044c.<\/p>\n<h2>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c <code>asyncpg<\/code>: <code>pip install querky[asyncpg]<\/code><\/p>\n<h4>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h4>\n<blockquote>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 <code>querky_def.py<\/code> \u0438 <code>querky_gen.py<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u043f\u043a\u0443 <code>sql<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <code>.py<\/code> \u0444\u0430\u0439\u043b\u044b \u0441 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0412 \u043f\u0430\u043f\u043a\u0435 <code>sql<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>__init__.py<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u043c.<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/p>\n<pre><code>sql |__ __init__.py querky_def.py querky_gen.py<\/code><\/pre>\n<h4>querky_def<\/h4>\n<p>\u0424\u0430\u0439\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438. \u0412 \u043d\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>qrk<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f Python \u0444\u0443\u043d\u043a\u0446\u0438\u0439 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438.<\/p>\n<pre><code class=\"python\">import os from querky.presets.asyncpg import use_preset   qrk = use_preset(os.path.dirname(__file__), type_factory='dataclass+slots')<\/code><\/pre>\n<blockquote>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u0435\u0441\u0435\u0442. \u0415\u0433\u043e \u0445\u0432\u0430\u0442\u0438\u0442 \u0434\u043b\u044f 95% \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u0447\u0435\u0447\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>Querky<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. <a href=\"https:\/\/github.com\/racinette\/querky#the-querky-class\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0443\u0442\u0435\u043c \u043a \u043a\u043e\u0440\u043d\u044e \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><code>type_factory<\/code> &#8212; \u044d\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044d\u0442\u043e <code>typed_dict<\/code>, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u043e \u0447\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/github.com\/racinette\/querky#type_factory\" rel=\"noopener noreferrer nofollow\">\u0435\u0441\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>Querky<\/code>. \u041e \u043d\u0438\u0445 \u043f\u043e\u0434\u0440\u043e\u043d\u0435\u0435 <a href=\"https:\/\/github.com\/racinette\/querky#the-querky-class\" rel=\"noopener noreferrer nofollow\">\u0442\u0430\u043a\u0436\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/li>\n<\/ul>\n<h4>querky_gen<\/h4>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043a\u043e\u0434\u0430. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u0442\u0438\u043f\u044b \u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b.<\/p>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u0435\u0441\u0435\u0442:<\/p>\n<pre><code class=\"python\">import asyncio  from querky.presets.asyncpg import generate  from querky_def import qrk import sql   if __name__ == \"__main__\":     asyncio.run(generate(qrk, \"&lt;\u0432\u0430\u0448 url \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043a postgres>\", base_modules=(sql, ))) <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <code>sql<\/code> \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u0440\u0442\u0435\u0436 <code>base_modules<\/code>. \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c <code>.py<\/code> \u0444\u0430\u0439\u043b\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0430\u043f\u043a\u0438 <code>sql<\/code> , \u0441\u043e\u0431\u0438\u0440\u0430\u044f \u0432\u0441\u0435 SQL \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043e\u0431\u0435\u0440\u0442\u043a\u0443. \u0412\u0441\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0442\u0438\u043f\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u044b \u0432 \u043f\u043e\u0434\u043f\u0430\u043f\u043a\u0435 <code>queries<\/code> \u0432 \u0444\u0430\u0439\u043b \u0441 \u0442\u0435\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439.<\/p>\n<blockquote>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442\u0443 <strong>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e<\/strong> \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a <em>\u0436\u0438\u0432\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/em>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0442\u0438\u043f\u044b, \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0438 \u0442.\u0434. \u0418\u043d\u0430\u0447\u0435 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c.<\/p>\n<\/blockquote>\n<h4>\u0421\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445: <strong>PostgreSQL 14.10<\/strong><\/p>\n<pre><code class=\"sql\">CREATE TABLE account (     id BIGSERIAL PRIMARY KEY,     username TEXT UNIQUE NOT NULL,     first_name TEXT NOT NULL,     last_name TEXT,     phone_number TEXT,     balance BIGINT NOT NULL DEFAULT 0,     join_ts TIMESTAMPTZ NOT NULL DEFAULT NOW(),     referred_by_account_id BIGINT REFERENCES account (id) );  CREATE TABLE post (     id BIGSERIAL PRIMARY KEY,     poster_id BIGINT NOT NULL REFERENCES account (id),     message TEXT NOT NULL,     ts TIMESTAMPTZ NOT NULL DEFAULT NOW() );  CREATE TABLE post_comment (     id BIGSERIAL PRIMARY KEY,     post_id BIGINT NOT NULL REFERENCES post (id),     commenter_id BIGINT NOT NULL REFERENCES account (id),     message TEXT NOT NULL,     ts TIMESTAMPTZ NOT NULL DEFAULT NOW() );<\/code><\/pre>\n<h4>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h4>\n<p>\u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c &#8212; \u044d\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>qrk<\/code>,  \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 <code>querky_def.py<\/code> , \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>query<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 <code>sql<\/code> \u0444\u0430\u0439\u043b <code>example.py<\/code> \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code>sql |__ __init__.py |__ example.py querky_def.py querky_gen.py<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e SQL \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">from querky_def import qrk   # \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 @qrk.query  # \u0438\u043b\u0438 \u044f\u0432\u043d\u043e: @qrk.query(shape='status') def update_account_phone_number(account_id, new_phone_number):     return f'''         UPDATE             account         SET             phone_number = {+new_phone_number}         WHERE             id = {+account_id}         '''   # \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 @qrk.query(shape='value', optional=False) def insert_account(username, first_name, last_name, phone_number, balance, referred_by_account_id):     return f'''         INSERT INTO             account             (                 username,                 first_name,                 last_name,                 phone_number,                 balance,                 referred_by_account_id             )         VALUES             (                 {+username},                 {+first_name},                 {+last_name},                 {+phone_number},                 {+balance},                 {+referred_by_account_id}             )         RETURNING             id         '''   # \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 @qrk.query(shape='column') def select_top_largest_balances(limit):     return f'''         SELECT             balance         FROM             account         ORDER BY             balance DESC         LIMIT             {+limit}         '''  # \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 AccountReferrer \u0438\u043b\u0438 None (optional=True) @qrk.query('AccountReferrer', shape='one', optional=True) def get_account_referrer(account_id):     return f'''         SELECT             referrer.id,             referrer.username,             referrer.first_name,             referrer.last_name,             referrer.join_ts          FROM              account          INNER JOIN             account AS referrer         ON             account.referred_by_account_id = referrer.id          WHERE             account.id = {+account_id}         '''   # \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0442\u0438\u043f\u0430 AccountPostComment @qrk.query('AccountPostComment', shape='many') def select_last_post_comments(post_id, limit):     return f'''         SELECT              account.first_name,             account.last_name,             post_comment.id,             post_comment.message          FROM             post_comment          INNER JOIN             account         ON             post_comment.commenter_id = account.id          WHERE             post_comment.post_id = {+post_id}          ORDER BY             post_comment.ts DESC          LIMIT             {+limit}         ''' <\/code><\/pre>\n<blockquote>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u0437\u043d\u0430\u043a\u043e\u043c <code>+<\/code>.<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e. <\/p>\n<ul>\n<li>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u043d\u0430\u0434\u043f\u0438\u0448\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e. <\/p>\n<\/li>\n<li>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u044f\u0432\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u0437 CamelCase-\u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0424\u043b\u0430\u0433 <code>optional<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0435\u0440\u043d\u0443\u0442\u044c <code>None<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c <em>\u0444\u043e\u0440\u043c\u0443<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<ul>\n<li>\n<p><code>status<\/code> &#8212; \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p><code>value<\/code> &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0444\u043b\u0430\u0433 <code>optional<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>column<\/code> &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0444\u043b\u0430\u0433 <code>optional<\/code> \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><code>one<\/code> &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043a\u043e\u0440\u0442\u0435\u0436. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0444\u043b\u0430\u0433 <code>optional<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>many<\/code> &#8212; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <em>\u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c<\/em>, \u0435\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438. <code>querky<\/code> \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u043e \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 <code>querky_gen.py<\/code>.  \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>example.py<\/code> \u0432 \u043f\u043e\u0434\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <code>sql\/queries<\/code>. \u0415\u0441\u043b\u0438 \u043f\u0430\u043f\u043a\u0438 <code>queries<\/code> \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. <\/p>\n<p>\u041d\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code>sql |__ __init__.py |__ example.py |__ queries     |__ example.py querky_def.py querky_gen.py<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0433\u043b\u044f\u043d\u0435\u043c \u0432\u043d\u0443\u0442\u0440\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 <code>sql\/queries\/example.py<\/code>:<\/p>\n<pre><code class=\"python\"># ~ AUTOGENERATED BY QUERKY ~ # import datetime from dataclasses import dataclass from asyncpg import Connection from sql.example import update_account_phone_number as _q0 from sql.example import insert_account as _q1 from sql.example import select_top_largest_balances as _q2 from sql.example import get_account_referrer as _q3 from sql.example import select_last_post_comments as _q4   async def update_account_phone_number(__conn: Connection, \/, account_id: int, new_phone_number: str) -> str:     return await _q0.execute(__conn, account_id, new_phone_number)   async def insert_account(__conn: Connection, \/, username: str, first_name: str, last_name: str, phone_number: str, balance: int, referred_by_account_id: int) -> int:     return await _q1.execute(__conn, username, first_name, last_name, phone_number, balance, referred_by_account_id)   async def select_top_largest_balances(__conn: Connection, \/, limit: int) -> list[int]:     return await _q2.execute(__conn, limit)   @dataclass(slots=True) class AccountReferrer:     id: int     username: str     first_name: str     last_name: str     join_ts: datetime.datetime   async def get_account_referrer(__conn: Connection, \/, account_id: int) -> AccountReferrer | None:     return await _q3.execute(__conn, account_id)  _q3.bind_type(AccountReferrer)   @dataclass(slots=True) class AccountPostComment:     first_name: str     last_name: str     id: int     message: str   async def select_last_post_comments(__conn: Connection, \/, post_id: int, limit: int) -> list[AccountPostComment]:     return await _q4.execute(__conn, post_id, limit)  _q4.bind_type(AccountPostComment)   __all__ = [     \"select_top_largest_balances\",     \"select_last_post_comments\",     \"AccountReferrer\",     \"get_account_referrer\",     \"AccountPostComment\",     \"update_account_phone_number\",     \"insert_account\", ] <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, <strong><u>\u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b \u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043e\u0442\u043c\u0435\u0442\u0438\u0432 \u0438\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u043c<\/u><\/strong>. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043e\u0431\u0435\u0440\u0442\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. <\/p>\n<h4>\u0418\u0442\u043e\u0433<\/h4>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0444\u043e\u0440\u043c\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0430\u043a, \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u043b\u044e\u0431\u043e\u0439 SQL \u0431\u0430\u0437\u043e\u0439: \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 f-string.<\/p>\n<ul>\n<li>\n<p><em>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 SQL \u0431\u0438\u043b\u0434\u0435\u0440\u043e\u0432, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 ORM, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 &#8212; \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u043b\u044e\u0431\u043e\u0439 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0444\u043e\u0440\u043c\u0435.<\/em><\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \/ \u0443\u0434\u0430\u043b\u044f\u0442\u0441\u044f \u0441\u0442\u0430\u0440\u044b\u0435 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0441\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <code>querky_gen.py<\/code>. <\/p>\n<p><em>\u0427\u0435\u0440\u0435\u0437 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u043d\u0438 \u0435\u0434\u0438\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430<\/em>.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u041d\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043b\u0438 \u043c\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435, \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430 \u0438 \u0442.\u0434. <\/p>\n<p><em>\u0417\u0430 \u043d\u0430\u0441 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043b\u0438\u043d\u0442\u0435\u0440<\/em>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 SQL \u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u043e <code>querky_gen.py<\/code> \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c, \u0432 \u043a\u0430\u043a\u043e\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043e\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430. <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0441\u0430\u0439\u0434-\u044d\u0444\u0444\u0435\u043a\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0438\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0432\u0430\u0448 RDBMS, \u0433\u0434\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <code>PREPARE<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0430\u0437\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443. <\/p>\n<p><em>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u0442\u044c \u043d\u0430 100% \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0446\u0435\u043b\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435<\/em>.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0430 \u0436\u0438\u0432\u043e\u0439 \u0431\u0430\u0437\u0435 \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c SQL, \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b &#8212; \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435, \u043d\u0430 \u0447\u0442\u043e \u0432\u0430\u0448 RDBMS \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d &#8212; \u0438 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0432\u0435\u0441\u044c type inference \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0447\u0430\u0441\u044b.<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e <strong>\u043d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e<\/strong>, \u0432\u0435\u0434\u044c \u0431\u044b\u0432\u0430\u044e\u0442 <a href=\"https:\/\/github.com\/racinette\/querky#return-types\" rel=\"noopener noreferrer nofollow\">NULLABLE \u043a\u043e\u043b\u043e\u043d\u043a\u0438<\/a>, <a href=\"https:\/\/github.com\/racinette\/querky#optionals\" rel=\"noopener noreferrer nofollow\">Optional \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b<\/a>, <a href=\"https:\/\/github.com\/racinette\/querky#enforce-type\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u0430\u0437\u044b<\/a>, \u0441\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c <a href=\"https:\/\/github.com\/racinette\/querky#different-queries---same-return-type\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/a> \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445, <a href=\"https:\/\/github.com\/racinette\/querky#default-values\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/a> \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0445, <a href=\"https:\/\/github.com\/racinette\/querky#query-reuse\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/a>. <\/p>\n<p>\u042f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u0434\u0435\u0442\u0430\u043b\u044f\u043c\u0438, \u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441\u0432\u0435\u0440\u0445\u0443 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 <a href=\"https:\/\/github.com\/racinette\/querky\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u044b \ud83d\ude42<\/p>\n<\/blockquote>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443 \u0442\u0430\u043a\u0436\u0435, \u0447\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0435\u0438\u043d\u0432\u0430\u0437\u0438\u0432\u043d\u0430: \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u0442\u043e\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u043c <code>querky<\/code> \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0435 <span class=\"habrahidden\">(\u0442\u043e\u043b\u044c\u043a\u043e asyncpg \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442)<\/span>.<\/p>\n<h2>\u041f\u043e\u0445\u043e\u0436\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/launchbadge\/sqlx\" rel=\"noopener noreferrer nofollow\">sqlx<\/a> &#8212; \u0434\u043b\u044f rust. \u041d\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u0438\u043f\u044b, \u043d\u043e \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0443 \u0432 \u043d\u0443\u0436\u043d\u044b\u0435 <code>struct<\/code>\u044b.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/sqlc-dev\/sqlc\" rel=\"noopener noreferrer nofollow\">sqlc<\/a> &#8212; \u0434\u043b\u044f go. \u0412\u044b \u043f\u0438\u0448\u0435\u0442\u0435 sql \u0442\u0438\u043f\u044b (\u0442\u0430\u0431\u043b\u0438\u0446\u044b) \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u043d\u0438\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 <code>.sql<\/code> \u0444\u0430\u0439\u043b\u0430\u0445, \u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 go \u043a\u043e\u0434 \u0434\u043b\u044f \u043d\u0438\u0445. <span class=\"habrahidden\">\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u0438\u043f\u0430\u0445 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437 .sql \u0444\u0430\u0439\u043b\u043e\u0432, \u0430 \u043d\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0435 \u043b\u0443\u0447\u0448\u0435 \u043c\u0435\u043d\u044f \u043d\u0435 \u0441\u043b\u0443\u0448\u0430\u0442\u044c, \u0430 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u0435\u0445, \u043a\u0442\u043e \u0438\u043c\u0435\u043b \u043e\u043f\u044b\u0442 \u0441 \u044d\u0442\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c.<\/span> <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pugsql.org\/tutorial\" rel=\"noopener noreferrer nofollow\">pugsql<\/a> &#8212; \u0434\u043b\u044f python. \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442\u0435\u043b\u044c sqlc \u0434\u043b\u044f go. \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u043f\u043e\u0445\u043e\u0436 \u043d\u043e \u0442\u0438\u043f\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f <code>dict<\/code>\u044b. \u041d\u0435\u0442 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.hugsql.org\/\" rel=\"noopener noreferrer nofollow\">hugsql<\/a> &#8212; \u0434\u043b\u044f closure. \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442\u0435\u043b\u044c sqlc \u0434\u043b\u044f go. \u0412\u0440\u043e\u0434\u0435 pugsql.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 querky<\/h2>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b, \u043c\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0436\u0435 \u0442\u0440\u0443\u0434\u0438\u0442\u0441\u044f. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0445\u0432\u0430\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u043d\u043b\u0430\u0439\u043d\u043e\u043c, \u043d\u043e \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e \u0432\u0441\u0435\u0445 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0438\u0433\u0440\u0443:<\/p>\n<p><a href=\"https:\/\/t.me\/cardusbot\" rel=\"noopener noreferrer nofollow\">https:\/\/t.me\/cardusbot<\/a><\/p>\n<p>\u0418\u0433\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u043c \u0447\u0430\u0442\u0435, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0431\u043e\u0442. \u0418\u0433\u0440\u0430 \u0432 <code>WebApp<\/code>, \u0442. \u0435. \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u0413\u0435\u0439\u043c\u043f\u043b\u0435\u0439 \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u0443 \u0437\u043d\u0430\u043a\u043e\u043c: \u043a\u0430\u0440\u0442\u043e\u0447\u043d\u0430\u044f \u0438\u0433\u0440\u0430 &#171;\u0414\u0443\u0440\u0430\u043a&#187;, \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u043a \u0438\u0433\u0440\u0435.<\/p>\n<p>\u0412\u0435\u0441\u044c \u0434\u0432\u0438\u0436\u043e\u043a \u0438\u0433\u0440\u044b \u0441\u0434\u0435\u043b\u0430\u043d \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043d\u0430 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 <code>querky<\/code>.  \u0412\u0441\u0435\u0433\u043e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 222 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 129 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/15c\/8fe\/b11\/15c8feb114ef227885d9d8993786ccff.png\" alt=\"\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u043e \u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435\" title=\"\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u043e \u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435\" width=\"1306\" height=\"281\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/15c\/8fe\/b11\/15c8feb114ef227885d9d8993786ccff.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432\u043e \u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ed0\/afe\/7e7\/ed0afe7e7cf67932665045bc5b2af3d4.png\" alt=\"\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\" title=\"\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\" width=\"1306\" height=\"281\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ed0\/afe\/7e7\/ed0afe7e7cf67932665045bc5b2af3d4.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u0430\u0441\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430<\/figcaption><\/div>\n<\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d28\/51b\/614\/d2851b614006ed9dfdd4e13de682c83d.png\" alt=\"\u0412\u043e\u0442 \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0430\u043f\u043a\u0430 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0412 \u043e\u0431\u0449\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u043e \u0434\u043e\u043c\u0435\u043d\u0430\u043c.\" title=\"\u0412\u043e\u0442 \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0430\u043f\u043a\u0430 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0412 \u043e\u0431\u0449\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u043e \u0434\u043e\u043c\u0435\u043d\u0430\u043c.\" width=\"244\" height=\"463\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d28\/51b\/614\/d2851b614006ed9dfdd4e13de682c83d.png\"\/><\/p>\n<div><figcaption>\u0412\u043e\u0442 \u043a\u0430\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0430\u043f\u043a\u0430 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0412 \u043e\u0431\u0449\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u043e \u0434\u043e\u043c\u0435\u043d\u0430\u043c.<\/figcaption><\/div>\n<\/figure>\n<p>\u0425\u043e\u0447\u0443 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0444\u0438\u0448\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0430 \u043c\u043d\u0435 \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u042f \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b ORM, \u043d\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043d\u0430\u043f\u0448\u043e\u0442\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437\u044b. \u0418 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0445\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">@qrk.query('Referral', shape='many', dict=True) def update_set_referrals(game_id, host_account_id):     return f'''         WITH          locked_account_id AS (             SELECT                  {account.id}                          FROM                 {account}             INNER JOIN                 {player}                          ON                 {player.account_id} = {account.id}                           WHERE                 {player.game_id} = {+game_id}                  AND {account.new}                 AND {account.id} &lt;> {+host_account_id}                      ORDER BY                 {account.id}                      FOR UPDATE         )         UPDATE             {account}         SET             {~account.new} = FALSE,             {~account.referred_by} = {+host_account_id}         FROM             {player}         WHERE             {account.id} = ANY(SELECT id FROM locked_account_id)         RETURNING             {account.id},             {account.name},             {account.tg_id}         '''<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<pre><code class=\"python\">from __future__ import annotations  import typing   T = typing.TypeVar('T')   class Column:     def __init__(self, t: Table, name: str):         self.table = t         self.name = name      def _str(self) -> str:         if self.table.noname__:             return self.name         else:             return f\"{self.table.name__}.{self.name}\"      def __invert__(self):         return self.name      def __str__(self):         return self._str()      def __repr__(self):         return self._str()   class Table:     def __init__(self, name: str, noname: bool):         self.name__ = name         self.noname__ = noname      def __getattr__(self, item: str) -> Column:         return Column(self, item)      def __str__(self):         return self.name__      def __repr__(self):         return self.name__   def get_database_name(t) -> str:     return t.__tablename__   def table(t: T, name: str | None = None) -> T:     return Table(name or get_database_name(t), noname=False) <\/code><\/pre>\n<p>\u0418 \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>table<\/code> \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0434\u0430\u0432\u0430\u044f \u043d\u0430 \u0432\u0445\u043e\u0434 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 <code>sqlalchemy<\/code> \u043c\u043e\u0434\u0435\u043b\u0438:<\/p>\n<pre><code class=\"python\">from mvc.models.sql.alchemy import (     Player,     Account )  player = table(Player) account = table(Account)<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u044b \u043e\u0431\u043c\u0430\u043d\u044b\u0432\u0430\u0435\u043c \u043f\u0430\u0439\u0447\u0430\u0440\u043c\u043e\u0432\u0441\u043a\u0438\u0439 \u043b\u0438\u043d\u0442\u0435\u0440. \u041e\u043d \u0434\u0443\u043c\u0430\u0435\u0442, \u0447\u0442\u043e <code>player<\/code> \u0438 <code>account<\/code> &#8212; \u044d\u0442\u043e <code>sqlalchemy<\/code> \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>table<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>T<\/code> \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438 <em>\u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0431\u044b<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>T<\/code> \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0438 \u0441\u0432\u043e\u044e \u0436\u0438\u0437\u043d\u044c: <\/p>\n<ul>\n<li>\n<p><em>\u043b\u0438\u043d\u0442\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u043c \u043f\u043e\u043b\u044f\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, <\/em><\/p>\n<\/li>\n<li>\n<p><em>\u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043a\u043e\u043c\u043f\u043b\u0438\u0442 \u043a\u043e \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044f\u043c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 &#8212; \u043e\u0447\u0435\u043f\u044f\u0442\u043e\u043a \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/em><\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u042f \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u044d\u0442\u043e\u0433\u043e \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0445\u0430\u043a, \u0438 \u0432\u0440\u044f\u0434 \u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u044b\u0439 \u043d\u0430 \u0432\u0441\u0435 IDE \u043c\u0435\u0442\u043e\u0434. \u041d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0433\u0440\u0435\u0445 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<\/blockquote>\n<h2>\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b<\/h2>\n<ul>\n<li>\n<p>\u041f\u043e\u0447\u0442\u0430: verolomnyy@gmail.com<\/p>\n<\/li>\n<li>\n<p>TG: <a href=\"https:\/\/t.me\/datscrazy\" rel=\"noopener noreferrer nofollow\">datscrazy<\/a><\/p>\n<\/li>\n<li>\n<p>github: <a href=\"https:\/\/github.com\/racinette\" rel=\"noopener noreferrer nofollow\">racinette<\/a><\/p>\n<\/li>\n<li>\n<p>SO: <a href=\"https:\/\/stackoverflow.com\/users\/13438431\/winwin\" rel=\"noopener noreferrer nofollow\">winwin<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/781982\/\"> https:\/\/habr.com\/ru\/articles\/781982\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0440\u0430\u0437\u0443 \u0445\u043e\u0447\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u0435\u043c\u0443, \u0430 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043c\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f Python, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 github \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 pip, \u0438 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0443\u0434\u0438\u0442\u0441\u044f \u0432 \u043c\u043e\u0435\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0438\u0433\u0440\u0435 \u043a\u0430\u043a SQL \u0434\u0432\u0438\u0436\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b ORM \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0442\u044c \u0440\u0430\u0437 \u0438\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f. \u041e\u0431 \u044d\u0442\u043e\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 (<a href=\"https:\/\/habr.com\/ru\/articles\/458286\/\" rel=\"noopener noreferrer nofollow\">1<\/a>, <a href=\"https:\/\/habr.com\/ru\/companies\/karuna\/articles\/774478\/\" rel=\"noopener noreferrer nofollow\">2<\/a>, <a href=\"https:\/\/habr.com\/ru\/articles\/667078\/\" rel=\"noopener noreferrer nofollow\">3<\/a>, <a href=\"https:\/\/habr.com\/ru\/companies\/hexlet\/articles\/271117\/\" rel=\"noopener noreferrer nofollow\">4<\/a>), \u0442\u0430\u043a \u0438 \u0432 \u0437\u0430\u0440\u0443\u0431\u0435\u0436\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u0445 (<a href=\"https:\/\/martinfowler.com\/bliki\/OrmHate.html\" rel=\"noopener noreferrer nofollow\">1<\/a>, <a href=\"https:\/\/kurapov.ee\/eng\/tech\/ORM-is-harfmul-pattern\/\" rel=\"noopener noreferrer nofollow\">2<\/a>, <a href=\"https:\/\/news.ycombinator.com\/item?id=36497613\" rel=\"noopener noreferrer nofollow\">3<\/a>, <a href=\"https:\/\/news.ycombinator.com\/item?id=11609719\" rel=\"noopener noreferrer nofollow\">4<\/a>). \u042d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u043e\u0431\u0449\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Object%E2%80%93relational_impedance_mismatch\" rel=\"noopener noreferrer nofollow\">Object-relational impedance mismatch<\/a>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044e \u0441\u0435\u0431\u0435 \u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043a\u0430\u043a &#171;\u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u043e\u0432&#187;.<\/p>\n<p>\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e ORM \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0438\u0441\u0442\u044b\u0445 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u044b\u0440\u044b\u0445 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c <em>\u043e\u0447\u0435\u043d\u044c \u0442\u044f\u0436\u0435\u043b\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445<\/em>.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0445\u0430\u0438\u0442\u044c ORM (<em>\u0434\u043e \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0431\u0435\u0437 \u043c\u0430\u043b\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u0430\u0434\u0435\u0441\u044f\u0442\u043a\u0430 \u043b\u0435\u0442<\/em>), \u043d\u043e \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 <em>\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e<\/em> \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u042f\u041f.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0443\u043b\u0430\u0442\u044b, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u043f\u0440\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<ol>\n<li>\n<p> \u041f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c SQL. \u0411\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Domain-specific_language\" rel=\"noopener noreferrer nofollow\">DSL<\/a>, \u0431\u0435\u0437 \u041e\u041e\u041f-\u043e\u0431\u0435\u0440\u0442\u043e\u043a, \u0431\u0435\u0437 SQL-\u0431\u0438\u043b\u0434\u0435\u0440\u043e\u0432. <\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0447\u0435\u043c\u0443?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, SQL &#8212; \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0435\u043e\u0431\u044b\u0447\u0435\u043d \u043e\u043d \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0410 \u0432\u0441\u0435 RDBMS, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0433\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e\u0442 (postgresql, mysql, mssql, sqlite, etc.), \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0443 \u044f\u0437\u044b\u043a\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u043c\u0443 \u0438\u0445 \u0431\u0438\u0437\u043d\u0435\u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c. \u0418 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u044d\u0442\u0438 \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u044b \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b \u0441\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 SQL. <\/p>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 (\u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u0441\u0435) ORM \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043e\u0431\u0449\u0438\u0439 \u043c\u0435\u0436\u0434\u0438\u0430\u043b\u0435\u043a\u0442\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 SQL \u043a\u043e\u0434\u0430. \u042d\u0442\u043e <em>\u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e <\/em>\u0440\u0435\u0448\u0430\u0435\u0442<em> <\/em>\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u044d\u0442\u0438\u043c \u0437\u0430\u043c\u044b\u043a\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 ORM \u043e\u0431\u0449\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432 \u0443\u0449\u0435\u0440\u0431 \u0447\u0430\u0441\u0442\u043d\u044b\u043c \u0441\u043b\u0443\u0447\u0430\u044f\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 RDBMS. <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 ORM \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0431\u0435\u0441\u0448\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0430 SQL \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. \u0421\u0447\u0438\u0442\u0430\u044e \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438 \u0440\u0435\u0434\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0447\u0438\u0441\u0442\u043e\u0433\u043e SQL \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0430 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044f\u043c \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 ORM \u0438 SQL-builder\u043e\u0432.<\/p>\n<\/div>\n<\/details>\n<ol start=\"2\">\n<li>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0435\u043c \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8212; \u044d\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430. <\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 f-string. <strong>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 <u>SQL \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0439<\/u>: \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0442\u0434\u0430\u0435\u043c \u043d\u0430 \u043e\u0442\u043a\u0443\u043f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>. <\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8212; \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0440\u043e\u043a\u0430, \u043a\u043e\u0440\u0442\u0435\u0436 (row) \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435: \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>User<\/code> \u0438 <code>Post<\/code>. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c <code>INNER JOIN<\/code> \u043f\u043e <code>user_id<\/code> \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>Post<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u043d\u0438\u0435\u043c <code>UserPost<\/code>. <\/p>\n<\/div>\n<\/details>\n<ol start=\"6\">\n<li>\n<p>\u0423 \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0438 <strong>\u044f\u0432\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/strong> <u>\u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/u>. <em>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043b\u0438\u043d\u0442\u0435\u0440 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0430 \u043d\u0430\u0448\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u043e\u0433\u0430\u0442\u044c \u043d\u0430\u043c \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0435<\/em>.<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0443\u043d\u043a\u0442\u044b 5 \u0438 6 \u0432\u044b\u043d\u0443\u0436\u0434\u0430\u044e\u0442 \u043d\u0430\u0441 \u043b\u0438\u0431\u043e <em>\u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u044f\u0432\u043d\u043e \u0432 \u043a\u043e\u0434\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e<\/em>, \u043b\u0438\u0431\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 <em>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438<\/em>. <strong>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u0443\u0442\u044c \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0445\u0435\u043c\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>. <\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b, \u043d\u043e \u0435\u0441\u0442\u044c \u0432 ORM:<\/p>\n<ol>\n<li>\n<p><strong>\u0422\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 SQL \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u044b<\/strong>. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, <a href=\"https:\/\/github.com\/tobymao\/sqlglot\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u0438\u0440\u0443\u044e\u0442 \u043a\u043e\u0434 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e SQL \u0434\u0438\u0430\u043b\u0435\u043a\u0442\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439<\/a>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438<\/strong>. ORM \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u044a\u0435\u043a\u0442 <code>sqlalchemy.orm.Session<\/code>). \u041c\u043e\u044f \u0436\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438 \u043f\u0443\u0441\u0442\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440.<\/p>\n<\/li>\n<\/ol>\n<h2>querky<\/h2>\n<p>\u0422\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u043c\u043e\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0437\u0432\u0430\u043b <strong>querky <\/strong>(<a href=\"https:\/\/github.com\/racinette\/querky\" rel=\"noopener noreferrer nofollow\">github<\/a>, <a href=\"https:\/\/pypi.org\/project\/querky\/\" rel=\"noopener noreferrer nofollow\">pypi<\/a>). \u0421\u0430\u043c\u043e \u0441\u043b\u043e\u0432\u043e &#8212; \u044d\u0442\u043e \u0441\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0445 \u0441\u043b\u043e\u0432 <em>query<\/em> (&#171;\u0437\u0430\u043f\u0440\u043e\u0441&#187;) \u0438 \u0441\u043e\u0437\u0432\u0443\u0447\u043d\u043e\u0433\u043e <em>quirky<\/em> (&#171;\u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439&#187;, &#171;\u043f\u0440\u0438\u0447\u0443\u0434\u043b\u0438\u0432\u044b\u0439&#187;).<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 <code>pip<\/code> \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>pip install querky<\/code><\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/racinette\/querky_showcase\" rel=\"noopener noreferrer nofollow\">\u0441\u043a\u0435\u043b\u0435\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438 \u043f\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0432 \u0440\u0443\u043a\u0430\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438. \u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 <a href=\"https:\/\/github.com\/racinette\/querky\/blob\/main\/README.md\" rel=\"noopener noreferrer nofollow\">README<\/a> \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0412\u00a0\u0441\u0442\u0430\u0442\u044c\u0435\u00a0\u0436\u0435 \u044f \u0445\u043e\u0447\u0443 \u0432\u00a0\u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u00a0\u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c <a href=\"https:\/\/github.com\/racinette\/querky#how-it-works\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u0447\u0435\u0442.<\/a><\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u0448\u0438\u0440\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0430\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0415\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0434\u0435\u0442\u0430\u043b\u044f\u043c, \u0442\u043e \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0443. <\/p>\n<p>\u041c\u043e\u0433\u0443 \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430, \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 Python \u043c\u043e\u0434\u0443\u043b\u0438. \u041e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/docs.python.org\/3\/library\/inspect.html\" rel=\"noopener noreferrer nofollow\">inspect<\/a>, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043a \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u044b\u043c \u044d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0442\u0435\u043c\u043f\u043b\u0435\u0439\u0442\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<\/div>\n<\/details>\n<p><em>\u0422\u0435\u043f\u0435\u0440\u044c \u0436\u0435 \u044f \u043e\u0431\u044f\u0437\u0430\u043d \u043e\u0433\u043e\u0440\u0447\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u043e\u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439<\/em>, \u043e\u0442\u043c\u0435\u0442\u0438\u0432, \u0447\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 <a href=\"https:\/\/github.com\/MagicStack\/asyncpg\" rel=\"noopener noreferrer nofollow\">asynpg<\/a>. <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 PostgreSQL Python \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432: <a href=\"https:\/\/github.com\/psycopg\/psycopg2\" rel=\"noopener noreferrer nofollow\">psycopg2<\/a>, <a href=\"https:\/\/github.com\/psycopg\/psycopg\" rel=\"noopener noreferrer nofollow\">psycopg<\/a> (aka <em>psycopg3<\/em>) \u0438 <a href=\"https:\/\/github.com\/aio-libs\/aiopg\" rel=\"noopener noreferrer nofollow\">aiopg<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c type-inference \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 RDBMS &#8212; \u043e\u0431 \u044d\u0442\u043e\u043c \u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u0440\u0435\u043a\u0430\u044e\u0441\u044c.<\/p>\n<h2>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c <code>asyncpg<\/code>: <code>pip install querky[asyncpg]<\/code><\/p>\n<h4>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h4>\n<blockquote>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 <code>querky_def.py<\/code> \u0438 <code>querky_gen.py<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u043f\u043a\u0443 <code>sql<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <code>.py<\/code> \u0444\u0430\u0439\u043b\u044b \u0441 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0412 \u043f\u0430\u043f\u043a\u0435 <code>sql<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>__init__.py<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u043c.<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/p>\n<pre><code>sql |__ __init__.py querky_def.py querky_gen.py<\/code><\/pre>\n<h4>querky_def<\/h4>\n<p>\u0424\u0430\u0439\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438. \u0412 \u043d\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>qrk<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f Python \u0444\u0443\u043d\u043a\u0446\u0438\u0439 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438.<\/p>\n<pre><code class=\"python\">import os from querky.presets.asyncpg import use_preset   qrk = use_preset(os.path.dirname(__file__), type_factory='dataclass+slots')<\/code><\/pre>\n<blockquote>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u0435\u0441\u0435\u0442. \u0415\u0433\u043e \u0445\u0432\u0430\u0442\u0438\u0442 \u0434\u043b\u044f 95% \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u0447\u0435\u0447\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>Querky<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. <a href=\"https:\/\/github.com\/racinette\/querky#the-querky-class\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/blockquote>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0443\u0442\u0435\u043c \u043a \u043a\u043e\u0440\u043d\u044e \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><code>type_factory<\/code> &#8212; \u044d\u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044d\u0442\u043e <code>typed_dict<\/code>, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u043e \u0447\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/github.com\/racinette\/querky#type_factory\" rel=\"noopener noreferrer nofollow\">\u0435\u0441\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>Querky<\/code>. \u041e \u043d\u0438\u0445 \u043f\u043e\u0434\u0440\u043e\u043d\u0435\u0435 <a href=\"https:\/\/github.com\/racinette\/querky#the-querky-class\" rel=\"noopener noreferrer nofollow\">\u0442\u0430\u043a\u0436\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/li>\n<\/ul>\n<h4>querky_gen<\/h4>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043a\u043e\u0434\u0430. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u0435\u0440\u0435\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435 \u0442\u0438\u043f\u044b \u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b.<\/p>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u0435\u0441\u0435\u0442:<\/p>\n<pre><code class=\"python\">import asyncio  from querky.presets.asyncpg import generate  from querky_def import qrk import sql   if __name__ == \"__main__\":     asyncio.run(generate(qrk, \"&lt;\u0432\u0430\u0448 url \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043a postgres>\", base_modules=(sql, ))) <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <code>sql<\/code> \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u0440\u0442\u0435\u0436 <code>base_modules<\/code>. \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c <code>.py<\/code> \u0444\u0430\u0439\u043b\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0430\u043f\u043a\u0438 <code>sql<\/code> , \u0441\u043e\u0431\u0438\u0440\u0430\u044f \u0432\u0441\u0435 SQL \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043e\u0431\u0435\u0440\u0442\u043a\u0443. \u0412\u0441\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0442\u0438\u043f\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u044b \u0432 \u043f\u043e\u0434\u043f\u0430\u043f\u043a\u0435 <code>queries<\/code> \u0432 \u0444\u0430\u0439\u043b \u0441 \u0442\u0435\u043c \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439.<\/p>\n<blockquote>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442\u0443 <strong>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e<\/strong> \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a <em>\u0436\u0438\u0432\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/em>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0442\u0438\u043f\u044b, \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0438 \u0442.\u0434. \u0418\u043d\u0430\u0447\u0435 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c.<\/p>\n<\/blockquote>\n<h4>\u0421\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445: <strong>PostgreSQL 14.10<\/strong><\/p>\n<pre><code class=\"sql\">CREATE TABLE account (     id BIGSERIAL PRIMARY KEY,     username TEXT UNIQUE NOT NULL,     first_name TEXT NOT NULL,     last_name TEXT,     phone_number TEXT,     balance BIGINT NOT NULL DEFAULT 0,     join_ts TIMESTAMPTZ NOT NULL DEFAULT NOW(),     referred_by_account_id BIGINT REFERENCES account (id) );  CREATE TABLE post (     id BIGSERIAL PRIMARY KEY,     poster_id BIGINT NOT NULL REFERENCES account (id),     message TEXT NOT NULL,     ts TIMESTAMPTZ NOT NULL DEFAULT NOW() );  CREATE TABLE post_comment (     id BIGSERIAL PRIMARY KEY,     post_id BIGINT NOT NULL REFERENCES post (id),     commenter_id BIGINT NOT NULL REFERENCES account (id),     message TEXT NOT NULL,     ts TIMESTAMPTZ NOT NULL DEFAULT NOW() );<\/code><\/pre>\n<h4>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/h4>\n<p>\u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c &#8212; \u044d\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>qrk<\/code>,  \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 <code>querky_def.py<\/code> , \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>query<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 <code>sql<\/code> \u0444\u0430\u0439\u043b <code>example.py<\/code> \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code>sql |__ __init__.py |__ example.py querky_def.py querky_gen.py<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e SQL \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"python\">from querky_def import qrk   # \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 @qrk.query  # \u0438\u043b\u0438 \u044f\u0432\u043d\u043e: @qrk.query(shape='status') def update_account_phone_number(account_id, new_phone_number):     return f'''         UPDATE             account         SET             phone_number = {+new_phone_number}         WHERE             id = {+account_id}         '''   # \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 @qrk.query(shape='value', optional=False) def insert_account(username, first_name, last_name, phone_number, balance, referred_by_account_id):     return f'''         INSERT INTO             account             (                 username,                 first_name,                 last_name,                 phone_number,                 balance,                 referred_by_account_id             )         VALUES             (                 {+username},                 {+first_name},                 {+last_name},                 {+phone_number},                 {+balance},                 {+referred_by_account_id}             )         RETURNING             id         '''   # \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-363509","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/363509","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=363509"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/363509\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=363509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=363509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=363509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}