{"id":1134,"date":"2020-05-27T00:01:29","date_gmt":"2020-05-26T15:01:29","guid":{"rendered":"https:\/\/www.kwonline.org\/memo2\/?p=1134"},"modified":"2020-05-28T22:54:04","modified_gmt":"2020-05-28T13:54:04","slug":"connect-postgresql-from-emacs","status":"publish","type":"post","link":"https:\/\/www.kwonline.org\/memo2\/2020\/05\/27\/connect-postgresql-from-emacs\/","title":{"rendered":"Emacs\u304b\u3089PostgreSQL\u306b\u63a5\u7d9a"},"content":{"rendered":"<p>Emacs\u304b\u3089PostgreSQL\u306b\u63a5\u7d9a\u3057\u305f\u3089\u697d\u3060\u3063\u305f\u306e\u3067\u30e1\u30e2<\/p>\n<p>Emacs\u3092\u8d77\u52d5\u5f8c\u3001sql-postgres\u30b3\u30de\u30f3\u30c9\u3067\u30b5\u30fc\u30d0\u30fc\u306b\u63a5\u7d9a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nM-x sql-postgres\r\n<\/pre>\n<p>\u30e6\u30fc\u30b6\u30fc\u540d\u30fb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u30fb\u30b5\u30fc\u30d0\u30fc\u3092\u5165\u529b\u3057\u3066\u63a5\u7d9a\u3002<br \/>\n.pgpass\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u3063\u3066\u304a\u3051\u3070\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u3057\u306a\u304f\u3066\u6e08\u3080\u3002<br \/>\n.pgpass\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u306f600\u306b\u3057\u3066\u304a\u304f\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#~\/.pgpass\r\nlocalhost:5432:\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9:\u30e6\u30fc\u30b6\u30fc:\u30d1\u30b9\u30ef\u30fc\u30c9\r\n<\/pre>\n<p>\u5225\u30d0\u30c3\u30d5\u30a1\u3067.sql\u30d5\u30a1\u30a4\u30eb\u3092sql-mode\u3067\u958b\u304f\u3002<br \/>\n\u69cb\u6587\u30cf\u30a4\u30e9\u30a4\u30c8\u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u3067ansi\u306a\u306e\u3067\u3001\u3053\u308c\u3092sql-set-product\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3063\u3066postgres\u306b\u5909\u3048\u308b<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nM-x sql-set-product \u23ce\r\npostgres\r\n<\/pre>\n<p>\u305d\u3057\u3066\u30d0\u30c3\u30d5\u30a1\u3068SQL\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u3092sql-set-sqli-buffer\u30b3\u30de\u30f3\u30c9\u3067\u95a2\u9023\u4ed8\u3051\u308b\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nM-x sql-set-sqli-buffer\r\n<\/pre>\n<p>\u300c*SQL*\u300d\u3068\u3044\u3046\u30d0\u30c3\u30d5\u30a1\u304c\u3042\u308b\u306e\u3067\u305d\u308c\u3092\u9078\u3076\u3002<br \/>\n\u3064\u306a\u304c\u3063\u305f\u3089\u300cC-c C-r\u300d\u3067\u30ea\u30fc\u30b8\u30e7\u30f3\u5185\u306e\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u51fa\u6765\u308b\u3002<\/p>\n<p>\u30d0\u30c3\u30d5\u30a1\u5185\u306e\u306e\u30af\u30a8\u30ea\u3092\u307e\u308b\u3054\u3068\u5b9f\u884c\u3059\u308b\u306a\u3089\u300cC-c C-b\u300d\u3067OK.<br \/>\n&nbsp;<br \/>\n<strong>\u304a\u307e\u3051<\/strong><br \/>\nSQL\u3092\u7de8\u96c6\u3059\u308b\u969b\u306b\u81ea\u52d5\u3067\u30a4\u30f3\u30c7\u30f3\u30c8\u3057\u3066\u304f\u308c\u305f\u3089\u697d\u3060\u306a\u3001\u3068\u601d\u3063\u305f\u3089sql-indent\u3066\u306e\u304c\u3042\u3063\u305f\u306e\u3067\u5165\u308c\u305f\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nM-x package-install \u23ce\r\nsql-indent\r\n<\/pre>\n<p>init.el\u306b\u8a2d\u5b9a\u3092\u8ffd\u8a18<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n(eval-after-load &quot;sql&quot;\r\n  '(load-library &quot;sql-indent&quot;))\r\n<\/pre>\n<p>\u3042\u3068\u3001sql-set-product\u3082\u81ea\u52d5\u3067\u3084\u3063\u3066\u3057\u307e\u3048\u3070\u697d\u306a\u306e\u3067\u305d\u306e\u8a2d\u5b9a\u3082init.el\u306b\u8ffd\u8a18<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n(defun sql-mode-hooks()\r\n  (sql-set-product &quot;postgres&quot;))\r\n(add-hook 'sql-mode-hook 'sql-mode-hooks)\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Emacs\u304b\u3089PostgreSQL\u306b\u63a5\u7d9a\u3057\u305f\u3089\u697d\u3060\u3063\u305f\u306e\u3067\u30e1\u30e2 Emacs\u3092\u8d77\u52d5\u5f8c\u3001sql-postgres\u30b3\u30de\u30f3\u30c9\u3067\u30b5\u30fc\u30d0\u30fc\u306b\u63a5\u7d9a M-x sql-postgres \u30e6\u30fc\u30b6\u30fc\u540d\u30fb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u30fb\u30b5\u30fc\u30d0\u30fc\u3092\u5165\u529b\u3057\u3066\u63a5\u7d9a\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1136,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8],"tags":[],"class_list":["post-1134","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-emacs","category-linux"],"_links":{"self":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/1134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/comments?post=1134"}],"version-history":[{"count":7,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/1134\/revisions"}],"predecessor-version":[{"id":1146,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/1134\/revisions\/1146"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/media\/1136"}],"wp:attachment":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/media?parent=1134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/categories?post=1134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/tags?post=1134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}