[英]Rake task to import sql database on localhost database
I try to import some data to my localhost project and i dont know what to do. 我尝试将一些数据导入到我的本地主机项目中,但我不知道该怎么办。 My task for this look like this right now:
我现在的任务如下所示:
desc "imports the devel databse dump file to www2_sw"
task :dumpimport => :environment do
puts "Loading www2_sw_development_dump.sql. Enter mysql root password. Just press Enter for none"
`sqlite3 development.sqlite3 < db/sql/geo_cities_states.sql`
end
But i have error: 但是我有错误:
Error: near line 5: near "AUTO_INCREMENT": syntax error
Error: near line 22: no such table: cities
Error: near line 573: no such table: cities
Error: near line 904: near "AUTO_INCREMENT": syntax error
Error: near line 914: no such table: states
Problem is that there is such table in my development database. 问题是我的开发数据库中有这样的表。 What i do wrong?
我做错了什么? How can i import my_database.sql to localhost development database.
我如何将my_database.sql导入localhost开发数据库。
This isn't a Rake or Ruby on Rails error. 这不是Rake或Ruby on Rails错误。 Have you tried running that command on the command line?
您是否尝试过在命令行上运行该命令?
The problem is that you're trying to import a MYSQL or PostgreSQL dump into SQLite. 问题是您正在尝试将MYSQL或PostgreSQL转储导入SQLite。
I don't think SQLite understands AUTO_INCREMENT
- I believe it should be AUTOINCREMENT
( SQLite AutoInc ) 我认为SQLite不了解
AUTO_INCREMENT
我认为它应该是AUTOINCREMENT
( SQLite AutoInc )
Try changing your DB to PostgreSQL or modify the dump to be SQLite compatible. 尝试将数据库更改为PostgreSQL或将转储修改为与SQLite兼容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.