如何将Heroku数据提取到本地SQLite3数据库中 [英] How to pull Heroku data into a local SQLite3 database

查看:174
本文介绍了如何将Heroku数据提取到本地SQLite3数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Rails应用程序中对数据进行本地备份,该应用程序已部署到Heroku,并遇到了问题.我按照 tap说明安装了Taps.

I'm trying to make a local backup of the data from my Rails application, which is deployed to Heroku, and running into problems. I followed the taps instructions and installed Taps.

我遇到两种错误.我在本地创建了一个SQLite数据库,并尝试使用以下命令提取数据:

I get two types of errors. I created a SQLite DB locally and tried pulling data with this command:

(sudo) heroku db:pull sqlite://Users/username/folder/testbackup.db

(sudo) heroku db:pull sqlite://username:password@localhost/Users/username/folder/testbackup.db

但是无论哪种方式我都能得到:

but either way I get this:

Failed to connect to database:
  Sequel::DatabaseConnectionError -> SQLite3::CantOpenException: could not open database: unable to open database file

或者,我尝试让Taps自动检测我的应用程序中的开发数据库并重写它,尽管那不是我想要的.然后我开始出现类似以下错误:

Alternatively, I tried letting Taps auto-detect the development DB in my app and rewrite it, though that isn't quite what I wanted. Then I start getting errors like:

/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:777:in `report_activate_error': RubyGem version error: sequel(3.15.0 not ~> 3.13.0) (Gem::LoadError)
  from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:211:in `activate'
  from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:1056:in `gem'
  from /Library/Ruby/Gems/1.8/gems/taps-0.3.10/bin/schema:4

最终

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/errors.rb:62:in `check': SQLite3::SQLException: PRIMARY KEY must be unique (Sequel::DatabaseError)

推荐答案

一些问题.首先,您的Sequel连接字符串是错误的.试试

A few issues. First, your Sequel connection string is wrong. Try

heroku db:pull sqlite:///Users/username/folder/testbackup.db

如果仍然遇到异常,则可能是由于权限问题所致,因此请确保可以写入该路径.

If you still get an exception, it may be due to a permission issue, so make sure you can write to that path.

您的Rubygem版本错误是因为当前版本的水龙头需要Sequel 3.13.0,并且您已经激活了3.15.0.您要么需要使用3.13.0,要么需要编辑taps gem规范以使用3.15.0.

Your Rubygem version error is because the current version of taps requires Sequel 3.13.0, and you already activated 3.15.0. You either need to use 3.13.0 or you need to edit the taps gem spec to use 3.15.0.

主键必须是唯一的,这是一个SQLite异常.没有完整的回溯和代码,很难猜测为什么会发生.

The PRIMARY KEY must be unique is an SQLite exception. Without the full backtrace and code it's hard to guess why it is occurring.

这篇关于如何将Heroku数据提取到本地SQLite3数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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