将sqlite更改为pg [英] Changing sqlite to pg

查看:106
本文介绍了将sqlite更改为pg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我解决这是我的初稿网站吗?

Could anyone help me with my problem this is my first draft website?

我的新问题:我的代码和postgres为何未连接

我已经尝试过StackOverflow解决方案,但是好像我一直遇到错误

I have tried of StackOverflow solutions but it just seems like I keep running into errors

这是我的 database.yml

default: &default
adapter: postgresql
pool: 5
timeout: 5000

development:
    adapter: postgresql
    encoding: unicode
    database: blog_development
    pool: 5
    username: opeodumakin
    password: 6391
    port: 3000
    host: localhost

test:
    adapter: postgresql
    encoding: unicode
    database: blog_development
    pool: 5
    username: opeodumakin
    password: 6391


production:
    <<: *default
    database: db/production.sqlite3

我一直收到此错误

供应商/缓存/宝石/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1013:in retrieve_connection'
vendor / cache / gems / activerecord-5.2.3 / lib / active_record / connection_handling.rb:118:in
retrieve_connection'
vendor / cache / gems / activerecord-5.2.3 / lib / active_record / connection_handling.rb:90:in connection'
供应商/缓存/宝石/activerecord-5.2.3/lib/active_record/migration.rb:554:in
call'
vendor / cache / gems / actionpack-5.2.3 / lib / action_dispatch / middleware / callbacks.rb:28:in 在调用中
vendor / cache / gems / activesupport-5.2.3 / lib / active_support / callbacks.rb:98:in
run_callbacks的
供应商/缓存/gems/actionpack-5.2.3/lib/action_dispatch/middleware/ callbacks.rb:26:in call'
vendor / cache / gems / actionpack-5.2.3 / lib / action_dispatch / middleware / executor.rb:14:in
致电'
v endor / cache / gems / actionpack-5.2.3 / lib / action_dispatch / middleware / debug_exceptions.rb:61:in call'
供应商/cache/gems/web-console-3.7.0 /lib/web_console/middleware.rb:135:in
call_app'
vendor / cache / gems / web-console-3.7.0 / lib / web_console / middleware.rb:30:in 阻止调用'
vendor / cache / gems / web-console-3.7.0 / lib / web_console / middleware.rb:20:in
catch'
vendor / cache / gems / web-console-3.7.0 / lib / web_console / middleware.rb:20:在中调用
vendor / cache / gems / actionpack-5.2.3 /lib/action_dispatch/middleware/show_exceptions.rb:33:in
call'
vendor / cache / gems / railties-5.2.3 / lib / rails / rack / logger.rb:38 :in call_app'
vendor / cache / gems / railties-5.2.3 / lib / rails / rack / logger.rb:26:in
阻止通话中'
vendor / cache / gems / activesupport-5.2.3 / lib / active_support / tagged_logging.rb:71:in 中已标记的
vendor / cache / gems / activesupport-5.2 .3 / lib / active_support / tagged_logging.rb:28:in
被标记为
的供应商/缓存/宝石/ activesuppo rt-5.2.3 / lib / active_support / tagged_logging.rb:71:in tagged'
vendor / cache / gems / railties-5.2.3 / lib / rails / rack / logger.rb :26:in
call'
vendor / cache / gems / sprockets-rails-3.2.1 / lib / sprockets / rails / quiet_assets.rb:13:in 呼叫
供应商/缓存/宝石/actionpack-5.2.3/lib/action_dispatch/middleware/remote_ip.rb:81:in
呼叫
供应商/缓存/宝石/ actionpack-5.2.3 / lib / action_dispatch / middleware / request_id.rb:27:in call'
vendor / cache / gems / rack-2.0.7 / lib / rack / method_override.rb :22:in
call'
vendor / cache / gems / rack-2.0.7 / lib / rack / runtime.rb:22:in call'
vendor / cache / gems / activesupport-5.2.3 / lib / active_support / cache / strategy / local_cache_middleware.rb:29:in
call'
vendor / cache / gems / actionpack- 5.2.3 / lib / action_dispatch / middleware / executor.rb:14:在中调用
供应商/缓存/gems/actionpack-5.2.3/lib/action_dispatch/middleware/static.rb :127:in
call'
vendor / cache / gems / rack-2.0.7 / lib / rack / sendfile.rb:111:in call'
vendor / cache / gems / railties-5.2.3 / lib / rails / engine.rb:524:in
call'
vendor / cache / gems / puma-3.12.1 /lib/puma/configuration.rb:227:in call'
vendor / cache / gems / puma-3.12.1 / lib / puma / server.rb:660:in
handle_request'
vendor / cache / gems / puma-3.12.1 / lib / puma / server.rb:474:in process_client'
vendor / cache / gems /puma-3.12.1/lib/puma/server.rb:334:in
运行中的块'
vendor / cache / gems / puma-3.12.1 / lib / puma / thread_pool .rb:135:in在 spawn_thread中的块中

vendor/cache/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1013:in retrieve_connection' vendor/cache/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:118:inretrieve_connection' vendor/cache/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:90:in connection' vendor/cache/gems/activerecord-5.2.3/lib/active_record/migration.rb:554:incall' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in block in call' vendor/cache/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:98:inrun_callbacks' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:26:in call' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:incall' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:61:in call' vendor/cache/gems/web-console-3.7.0/lib/web_console/middleware.rb:135:incall_app' vendor/cache/gems/web-console-3.7.0/lib/web_console/middleware.rb:30:in block in call' vendor/cache/gems/web-console-3.7.0/lib/web_console/middleware.rb:20:incatch' vendor/cache/gems/web-console-3.7.0/lib/web_console/middleware.rb:20:in call' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/show_exceptions.rb:33:incall' vendor/cache/gems/railties-5.2.3/lib/rails/rack/logger.rb:38:in call_app' vendor/cache/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:inblock in call' vendor/cache/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in block in tagged' vendor/cache/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:28:intagged' vendor/cache/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in tagged' vendor/cache/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:incall' vendor/cache/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in call' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/remote_ip.rb:81:incall' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb:27:in call' vendor/cache/gems/rack-2.0.7/lib/rack/method_override.rb:22:incall' vendor/cache/gems/rack-2.0.7/lib/rack/runtime.rb:22:in call' vendor/cache/gems/activesupport-5.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:incall' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:in call' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/static.rb:127:incall' vendor/cache/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in call' vendor/cache/gems/railties-5.2.3/lib/rails/engine.rb:524:incall' vendor/cache/gems/puma-3.12.1/lib/puma/configuration.rb:227:in call' vendor/cache/gems/puma-3.12.1/lib/puma/server.rb:660:inhandle_request' vendor/cache/gems/puma-3.12.1/lib/puma/server.rb:474:in process_client' vendor/cache/gems/puma-3.12.1/lib/puma/server.rb:334:inblock in run' vendor/cache/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'

推荐答案


  1. ADD

  1. ADD

gem 'pg', '0.18.3'


  • 更新数据库。yml

  • Update your database.yml

    connection: &connection
      adapter: postgresql
      host: <%= ENV.fetch('DB_1_PORT_5432_TCP_ADDR', 'localhost') %>
      port: <%= ENV.fetch('DB_1_PORT_5432_TCP_PORT', '5432') %>
      username: postgres
      password: postgres
      pool: 5
      timeout: 5000
    
    development:
      <<: *connection
      database: development_db_name
    test:
      <<: *connection
      database: test_db_name
    
    production:
      <<: *connection
      database: production_db_name
    


  • 重新启动服务器

  • Restart your server

    这篇关于将sqlite更改为pg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆