SQLite 3 数据库无法正确读取

发布于 2024-12-11 20:03:40 字数 636 浏览 1 评论 0原文

我必须在 Rails 3.1.1 应用程序中手动创建 sqlite3 数据库,使用 mysql2sqlite 工具,然后运行:

sqlite3 development.sqlite3 < mysql2sqlite_dump.sql

无论如何,development.sqlite3 文件就在那里,服务器启动正常,所有页面加载正常(没有数据库错误)关于丢失的表或任何东西),但是数据没有被读取......就像它不存在一样。例如,即使在控制台中运行 Event.all 也会给我:

  Event Load (0.1ms)  SELECT "events".* FROM "events" 
 => [] 

当实际上应该有多个事件时。查看 sqlite3 文件,我可以看到所有信息都在那里,但只是没有被读取。如果有人要求,我将发布部分数据库文件。

我的问题是:为什么数据库没有被正确读取,我该如何做到这一点?

谢谢。

I had to create a sqlite3 database in my rails 3.1.1 app manually, converting from a mysql database using the mysql2sqlite tool, and then running:

sqlite3 development.sqlite3 < mysql2sqlite_dump.sql

Anyways, the development.sqlite3 file is there, and the server starts up fine and all the pages are loading fine (no database errors about missing tables or anything), but the data isn't being read... just as if it wasn't there. Even running Event.all, for example, in console gives me :

  Event Load (0.1ms)  SELECT "events".* FROM "events" 
 => [] 

When there should actually be several events. Looking in the sqlite3 file, I can see that all the information is there, but it's just not being read. I will post part of the database file if anybody requests it.

My question is: Why isn't the database being read properly, and how can I make it so?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桃扇骨 2024-12-18 20:03:40

嗯,我似乎已经解决了这个问题。问题是 mysqldump(在 mysql2sqlite 脚本内执行)正在删除然后创建表(默认情况),这与架构文件冲突。因此,我根据架构文件创建了数据库,然后再次运行脚本,并为 mysqldump 添加了 --no-create-info 选项,以便它只插入的信息。

谢谢大家的帮助!

Well, I seemed to have solved the problem. The issue was that mysqldump (being executed inside of the mysql2sqlite script) was dropping and then creating the tables (which is default), and that was conflicting with the schema file. So, I created the database according the schema file, and then ran the script again with the --no-create-info option added for mysqldump so that it would only insert the information.

Thanks for the help everybody!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文