如何将heroku数据导入本地SQLite3数据库?遇到问题 [英] How do I pull heroku data into a local SQLite3 database? Running into problems

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

问题描述

我试图从部署到Heroku的Rails应用程序对数据进行本地备份,并遇到问题。我遵循这里的指示: http://docs.heroku.com/taps 并安装了Taps。



我得到两种类型的错误。我在本地创建了一个SQLite数据库,并尝试使用此命令提取数据:
$ b


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


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


但是无论如何我得到这个:


无法连接数据库:
Sequel :: DatabaseConnectionError - > SQLite3 :: CantOpenException :无法打开数据库:无法打开数据库文件

或者,我尝试让Tap在我的应用程序中自动检测开发数据库,重写它,虽然这不是我想要的。然后我开始收到如下错误:


/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:777:in report_activate_error':RubyGem版本错误:sequel(3.15.0 not〜> 3.13.0)(Gem :: LoadError)$ / b / b / from /opt/local/lib/ruby/site_ruby/1.8/rubygems .rb:211:在中激活'从/ Library中激活'/b$/local/lib/ruby/site_ruby/1.8/rubygems.rb:1056:in'gem'
'中的
/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:在'check'中:SQLite3 :: SQLException:PRIMARY KEY必须是唯一的(Sequel :: DatabaseError)

非常重要的一点是,我会尽快备份这些数据! 解决方案

几个问题。首先,你的Sequel连接字符串是错误的。试试

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

如果您仍然遇到异常,可能是由于权限问题,请确保您可以写入该路径。 p>

您的Rubygem版本错误是因为当前版本的水龙头需要Sequel 3.13.0,并且您已经激活了3.15.0。您需要使用3.13.0,或者您需要编辑轻敲宝石规格以使用3.15.0。



PRIMARY KEY必须是唯一的,这是SQLite例外。没有完整的回溯和代码,很难猜测它为什么会发生。

I'm trying to make a local backup of the data from my Rails app, which is deployed to Heroku, and running into problems. I followed the instructions here: http://docs.heroku.com/taps and installed Taps.

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

or

(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

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:inactivate' 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

and eventually

/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)

Thanks tons in advance, it's pretty important that I start backing up this data as soon as possible!

解决方案

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.

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.

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天全站免登陆