{
    "componentChunkName": "component---src-templates-blog-post-jsx",
    "path": "/post/how-to-connect-database-with-database-uri-without-config/",
    "result": {"data":{"site":{"siteMetadata":{"title":"WEB EGG","author":"Leko - CTO at Yuimedi"}},"markdownRemark":{"id":"288dbe7b-ac2d-53cd-8b44-37aecb094a24","excerpt":"れこです。今回はRailsネタです。 作ったアプリをHerokuにデプロイするときに、各種アドオンで のような文字列を環境変数で指定して使うというパターンが有ると思うのですが、 config/database.ymlに一切触らず に、この文字列でDB接続したい… と思ったのでRails…","html":"<p>れこです。今回はRailsネタです。<br>\n作ったアプリをHerokuにデプロイするときに、各種アドオンで</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">XXX_URL=pg://xxx:yyy@zzz/hoge</code></pre></div>\n<p>のような文字列を環境変数で指定して使うというパターンが有ると思うのですが、<br>\n<strong>config/database.ymlに一切触らず</strong> に、この文字列でDB接続したい…</p>\n<p>と思ったのでRailsのソースやドキュメントを読み漁ってみました。</p>\n<!--more-->\n<h2 id=\"結論\" style=\"position:relative;\"><a href=\"#%E7%B5%90%E8%AB%96\" aria-label=\"結論 permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>結論</h2>\n<p>先に結論を書くと、何もせずとも<code>DATABASE_URL</code>という名前の環境変数を定義すればOKでした。<br>\nconfig/database.ymlを書き換えたり消したりする必要はなく、環境変数が優先されます。</p>\n<p>以下はこの結論に至った経緯とおまけです。</p>\n<h2 id=\"ドキュメントを読んでみる\" style=\"position:relative;\"><a href=\"#%E3%83%89%E3%82%AD%E3%83%A5%E3%83%A1%E3%83%B3%E3%83%88%E3%82%92%E8%AA%AD%E3%82%93%E3%81%A7%E3%81%BF%E3%82%8B\" aria-label=\"ドキュメントを読んでみる permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ドキュメントを読んでみる</h2>\n<p>まずは何事にも公式ドキュメント。</p>\n<blockquote>\n<p>You can connect to the database by setting an environment variable <code>ENV['DATABASE_URL']</code> or by using a configuration file called <code>config/database.yml</code>.<br>\n<a href=\"http://edgeguides.rubyonrails.org/configuring.html#configuring-a-database\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">3.14 Configuring a Database</a></p>\n</blockquote>\n<p>とあるように、<code>DATABASE_URL</code>という環境変数が使用可能らしいということがわかりました。<br>\nここで気になったのは、 <strong>config/database.ymlと環境変数どちらが優先されるのか</strong> 。<br>\nドキュメントだけでは解消しないので詳しく追ってみます。</p>\n<h2 id=\"記事を探してみる\" style=\"position:relative;\"><a href=\"#%E8%A8%98%E4%BA%8B%E3%82%92%E6%8E%A2%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B\" aria-label=\"記事を探してみる permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>記事を探してみる</h2>\n<p>試してみた系記事ないかなーと探してみたらこんな記事が。</p>\n<blockquote>\n<p><a href=\"http://www.johng.co.uk/2014/04/29/rails-41-database-urls/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">John Griffin: Rails 4.1: Database URLs</a></p>\n</blockquote>\n<p>結局どっちなのかわからん。</p>\n<h2 id=\"railsのソースを読んでみる\" style=\"position:relative;\"><a href=\"#rails%E3%81%AE%E3%82%BD%E3%83%BC%E3%82%B9%E3%82%92%E8%AA%AD%E3%82%93%E3%81%A7%E3%81%BF%E3%82%8B\" aria-label=\"railsのソースを読んでみる permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Railsのソースを読んでみる</h2>\n<p>まずはそれっぽいテストがないか確認。<br>\n<a href=\"https://github.com/rails/rails/search?utf8=%E2%9C%93&#x26;q=DATABASE_URL\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GithubのRailsのソースを検索してみた</a>。</p>\n<p><a href=\"https://github.com/rails/rails/blob/b326e82dc012d81e9698cb1f402502af1788c1e9/railties/test/application/initializers/frameworks_test.rb#L251\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">このテスト</a>と<a href=\"https://github.com/rails/rails/blob/3fc0bbf008f0e935ab56559f119c9ea8250bfddd/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">このファイルのテスト</a>をみる限り、config/database.ymlよりも環境変数が優先されそうな気がする。</p>\n<p>ソースを読んでみるとそれっぽい（？）記述が。</p>\n<div class=\"gatsby-highlight\" data-language=\"ruby\"><pre class=\"language-ruby\"><code class=\"language-ruby\"><span class=\"token comment\"># Returns fully resolved connection hashes.</span>\n<span class=\"token comment\"># Merges connection information from `ENV['DATABASE_URL']` if available.</span>\n<span class=\"token keyword\">def</span> <span class=\"token method-definition\"><span class=\"token function\">resolve</span></span>\n  <span class=\"token constant\">ConnectionAdapters</span><span class=\"token punctuation\">:</span><span class=\"token punctuation\">:</span><span class=\"token constant\">ConnectionSpecification</span><span class=\"token punctuation\">:</span><span class=\"token punctuation\">:</span><span class=\"token constant\">Resolver</span><span class=\"token punctuation\">.</span><span class=\"token keyword\">new</span><span class=\"token punctuation\">(</span>config<span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>resolve_all\n<span class=\"token keyword\">end</span>\n\n<span class=\"token keyword\">private</span>\n  <span class=\"token keyword\">def</span> <span class=\"token method-definition\"><span class=\"token function\">config</span></span>\n    <span class=\"token variable\">@raw_config</span><span class=\"token punctuation\">.</span>dup<span class=\"token punctuation\">.</span>tap <span class=\"token keyword\">do</span> <span class=\"token operator\">|</span>cfg<span class=\"token operator\">|</span>\n      <span class=\"token keyword\">if</span> url <span class=\"token operator\">=</span> <span class=\"token constant\">ENV</span><span class=\"token punctuation\">[</span><span class=\"token string\">\"DATABASE_URL\"</span><span class=\"token punctuation\">]</span>\n        cfg<span class=\"token punctuation\">[</span><span class=\"token variable\">@env</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">||</span><span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span>\n        cfg<span class=\"token punctuation\">[</span><span class=\"token variable\">@env</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">[</span><span class=\"token string\">\"url\"</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">||</span><span class=\"token operator\">=</span> url\n      <span class=\"token keyword\">end</span>\n    <span class=\"token keyword\">end</span>\n  <span class=\"token keyword\">end</span></code></pre></div>\n<p>該当ファイルは<a href=\"https://github.com/rails/rails/blob/bb1ecdcc677bf6e68e0252505509c089619b5b90/activerecord/lib/active_record/connection_handling.rb#L76\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">rails/activerecord/lib/active_record/connection_handling.rb</a>。<br>\nもしDATABASE_URLという環境変数があれば設定ファイルでいうところの</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">development</span><span class=\"token punctuation\">:</span> <span class=\"token comment\"># ※ここは実行時の環境による</span>\n  <span class=\"token key atrule\">url</span><span class=\"token punctuation\">:</span> &lt;%%= ENV<span class=\"token punctuation\">[</span><span class=\"token string\">'DATABASE_URL'</span><span class=\"token punctuation\">]</span> %<span class=\"token punctuation\">></span></code></pre></div>\n<p>に相当する処理を内部でやってくれる模様。<br>\nただ、設定ファイルを見てみると</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token comment\"># On Heroku and other platform providers, you may have a full connection URL</span>\n<span class=\"token comment\"># available as an environment variable. For example:</span>\n<span class=\"token comment\">#</span>\n<span class=\"token comment\">#   DATABASE_URL=\"postgres://myuser:mypass@localhost/somedatabase\"</span>\n<span class=\"token comment\">#</span>\n<span class=\"token comment\"># You can use this database configuration with:</span>\n<span class=\"token comment\">#</span>\n<span class=\"token comment\">#   production:</span>\n<span class=\"token comment\">#     url: &lt;%%= ENV['DATABASE_URL'] %></span>\n<span class=\"token comment\">#</span></code></pre></div>\n<p>と<a href=\"https://github.com/rails/rails/blob/3df3d80ade705dd096ec481845ff0fc2d70427b0/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">設定ファイルを書き換えるようコメントが書かれていたり</a>、いまいちどっちを信じればよいのかわからない。</p>\n<h2 id=\"実験してみる\" style=\"position:relative;\"><a href=\"#%E5%AE%9F%E9%A8%93%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B\" aria-label=\"実験してみる permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>実験してみる</h2>\n<p>英語とRuby力が足らず決定打が見つからなかったので試してみました。<br>\n<a href=\"http://www.johng.co.uk/2014/04/29/rails-41-database-urls/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">参考記事</a>のコマンドをお借りして試してみます。</p>\n<ul>\n<li>config/database.yml上ではSQLiteで接続するよう設定(gem等も入れとく)</li>\n<li>ローカルにPostgreSQLは入っていない</li>\n</ul>\n<p>という状態で下記コマンドを実行して、ポスグレで接続しようとすれば接続エラーになるはず。<br>\nもしconfig/database.ymlが優先されるならSQLiteの接続になるので正しく接続できてしまう</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># 接続エラー（ポスグレで接続しようとしている）\nDATABASE_URL=postgresql://localhost/app_development bundle exec rails s\n\n# 接続できた（config/database.ymlは間違ってない）\nbundle exec rails s</code></pre></div>\n<p>ということで試してみた結果、<br>\n<strong>config/database.ymlが存在しようと、環境変数が指定されていればそちらが優先される</strong><br>\nということがわかりました。</p>\n<h2 id=\"まとめ\" style=\"position:relative;\"><a href=\"#%E3%81%BE%E3%81%A8%E3%82%81\" aria-label=\"まとめ permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>まとめ</h2>\n<p>この形式は環境変数１個で事足りるし、.env等に逃がせば接続情報をGit管理しなくて良くなるので、とても好きです。<br>\nデータベースにかぎらず、RedisやSMTPサーバなんかもこの書式で表現できます。<br>\n各DBドライバによって必要な設定のキー名が変わるとか面倒くさくて覚えたくないので、接続系の処理はこの書き方に統一されてしまえばいいのに、なんて思ってます。</p>\n<p>RailsアプリはHerokuにデプロイされることが多いからなのか、デフォルトで対応してくれていて助かりました。<br>\nさすがRails。といったところなんでしょうか。</p>\n<p>ちなみにこの書き方ってなんて名称なんでしょう。<br>\n私は<code>url string</code>とか<code>connection string</code>なんて検索をしているのですが、正しい名前があれば知りたい。。。</p>\n<h2 id=\"おまけ多言語の対応状況\" style=\"position:relative;\"><a href=\"#%E3%81%8A%E3%81%BE%E3%81%91%E5%A4%9A%E8%A8%80%E8%AA%9E%E3%81%AE%E5%AF%BE%E5%BF%9C%E7%8A%B6%E6%B3%81\" aria-label=\"おまけ多言語の対応状況 permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>おまけ：多言語の対応状況</h2>\n<p>私がよく触る言語たちの対応状況を調べてみました。</p>\n<h3 id=\"php\" style=\"position:relative;\"><a href=\"#php\" aria-label=\"php permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>PHP</h3>\n<p>CakePHPだと対応している模様。<br>\n<a href=\"http://book.cakephp.org/3.0/en/development/configuration.html#environment-variables\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http://book.cakephp.org/3.0/en/development/configuration.html#environment-variables</a></p>\n<p>Laravelだと、この形式でDB接続するのに対応してないので、<br>\n<a href=\"http://www.easylaravelbook.com/blog/2015/01/31/deploying-a-laravel-application-to-heroku/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">この記事</a>のように設定ファイルにPHPの処理を書き加えてLaravelの設定に互換性があるようにパース処理を自前で実装しなきゃいけなかったりクソ面倒です。</p>\n<p>FuelPHPも探してみたものの、それらしい記事が見つからず。</p>\n<h3 id=\"nodejs\" style=\"position:relative;\"><a href=\"#nodejs\" aria-label=\"nodejs permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Nodejs</h3>\n<p>新進気鋭のフレームワーク<a href=\"http://www.adonisjs.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Adonis</a>や個人的に好きなO/Rマッパーの<a href=\"https://github.com/Vincit/objection.js\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">objection</a>が内部で使用している<a href=\"http://knexjs.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">knex</a>はもちろん対応しています。</p>\n<p>Nodeはフルスタックなフレームワークが少ない（流行ってない）ので、内部的にknexを使ってればOKくらいの認識で居ます</p>\n<h3 id=\"go\" style=\"position:relative;\"><a href=\"#go\" aria-label=\"go permalink\" class=\"autolink-header before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Go</h3>\n<p>Goは別格です。<br>\nあらゆるDBのドライバの根っこになっている<a href=\"https://golang.org/pkg/database/sql/#Open\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">database/sql</a>パッケージがデフォルトで対応しています。<br>\nなのでdatabase/sqlパッケージを使わずにオレオレ実装でもしていない限り対応してます。</p>\n<p>昔に作った<a href=\"https://github.com/Leko/godemo/blob/master/database/postgres.go#L40\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Goのデモアプリ</a>でもこの方式を利用しています。</p>","timeToRead":7,"frontmatter":{"title":"Railsでconfig/database.ymlを使わずURL文字列でDB接続したい","tags":["Go","Nodejs","Ruby","Ruby on Rails"],"date":"September 30, 2016","featuredImage":null}}},"pageContext":{"slug":"/how-to-connect-database-with-database-uri-without-config/","previous":{"fields":{"slug":"/automate-deploy-to-rubygems-with-circleci/"},"frontmatter":{"title":"RubygemsへのデプロイをCircleCIで自動化してみた","tags":["CircleCI","Ruby","Rubygems"]}},"next":{"fields":{"slug":"/learn-makefile/"},"frontmatter":{"title":"Makefile初めて触った。めっちゃ簡単だった","tags":["CLI"]}}}},
    "staticQueryHashes": ["2585454260","2954598359"]}