{"id":8404,"date":"2022-07-25T20:14:11","date_gmt":"2022-07-25T11:14:11","guid":{"rendered":"https:\/\/yumishin.com\/?p=8404"},"modified":"2022-07-25T20:14:11","modified_gmt":"2022-07-25T11:14:11","slug":"ruby-postgres","status":"publish","type":"post","link":"https:\/\/yumishin.com\/?p=8404","title":{"rendered":"\u3010Ruby\u30fbPG\u3011Ruby\u3092\u4f7f\u3063\u3066postgres\u306b\u63a5\u7d9a\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<h2 id=\"i-0\">\u3010Ruby\u30fbPG\u3011Ruby\u3092\u4f7f\u3063\u3066postgres\u306b\u63a5\u7d9a\u3059\u308b\u65b9\u6cd5<\/h2>\n<p>\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3001\u5927\u4e08\u592b\u3067\u3059\uff01<\/p>\n<div class=\"pre_tag\"><span><i class=\"fa fa-code\"><\/i> \u30b3\u30fc\u30c9<\/span><\/p>\n<pre><code>\thost = String('mydemoserver.postgres.database.azure.com')\n\tdatabase = String('postgres')\n    user = String('mylogin%40mydemoserver')\n\tpassword = String('')\n\n\t# Initialize connection object.\n    connection = PG::Connection.new(:host =&gt; host, :user =&gt; user, :dbname =&gt; database, :port =&gt; '5432', :password =&gt; password)\n    puts 'Successfully created connection to database.'\n\n    resultSet = connection.exec('SELECT * from inventory;')\n    resultSet.each do |row|\n        puts 'Data row = (%s, %s, %s)' % [row['id'], row['name'], row['quantity']]\n    end\n<\/code><\/pre>\n<\/div>\n<p>\u203b require \u2018pg\u2019\u7684\u306a\u8a18\u8ff0\u304c\u5fc5\u8981\u3067\u3059\u306e\u3067\u3001\u305d\u308c\u3060\u3051\u8981\u6ce8\u610f\u3067\u3059\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3010Ruby\u30fbPG\u3011Ruby\u3092\u4f7f\u3063\u3066postgres\u306b\u63a5\u7d9a\u3059\u308b\u65b9\u6cd5 \u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3001\u5927\u4e08\u592b\u3067\u3059\uff01 \u203b require \u2018pg\u2019\u7684\u306a\u8a18\u8ff0\u304c\u5fc5\u8981\u3067\u3059\u306e\u3067\u3001\u305d\u308c\u3060\u3051\u8981\u6ce8\u610f\u3067\u3059\uff01<\/p>\n","protected":false},"author":1,"featured_media":8405,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[256],"tags":[],"class_list":{"0":"post-8404","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-it","8":"entry"},"_links":{"self":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/8404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8404"}],"version-history":[{"count":1,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/8404\/revisions"}],"predecessor-version":[{"id":8406,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/posts\/8404\/revisions\/8406"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=\/wp\/v2\/media\/8405"}],"wp:attachment":[{"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yumishin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}