Rake任务在localhost数据库上导入sql数据库(Rake task to import sql database on localhost database)

编程入门 行业动态 更新时间:2024-10-28 16:29:04
Rake任务在localhost数据库上导入sql数据库(Rake task to import sql database on localhost database)

我尝试将一些数据导入我的localhost项目,我不知道该怎么做。 我现在的任务看起来像这样:

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

但我有错误:

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

问题是我的开发数据库中有这样的表。 我做错了什么? 如何将my_database.sql导入localhost开发数据库。

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.

最满意答案

这不是Rake或Ruby on Rails错误。 您是否尝试在命令行上运行该命令?

问题是您正在尝试将MYSQL或PostgreSQL转储导入SQLite。

我不认为SQLite理解AUTO_INCREMENT - 我认为它应该是AUTOINCREMENT ( SQLite AutoInc )

尝试将数据库更改为PostgreSQL或将转储修改为SQLite兼容。

This isn't a Rake or Ruby on Rails error. 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.

I don't think SQLite understands AUTO_INCREMENT - I believe it should be AUTOINCREMENT (SQLite AutoInc)

Try changing your DB to PostgreSQL or modify the dump to be SQLite compatible.

更多推荐

本文发布于:2023-04-29 12:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336243.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   localhost   Rake   sql   database

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!