解决ruby - How can I migrate my data from my rails app from mySql to SQLite
1. 计算年数 你想通过生日来计算这个人有几岁了。 1 SELECT DATE_FORMAT(FROM_DAYS(TO_DAYS(now()) - TO_DAYS(@dateofbirth)), '%Y' ) + 0; 2. 两个时间的差 取
How can I migrate my data from my rails app from mySql to SQLite?
Is this possible?ruby-on-rails ruby sqlite migration
this question edited Nov 16 '09 at 9:25 Simone Carletti 130k 27 273 313 asked Nov 14 '09 at 21:06 Verhogen 8,238 26 68 98
In the past I had to migrate Gb of databases from SQlite to MySQL to PostgreSQl and viceversa. I tried tons of utilities, scripts and tools but the only way I found to successfully migrate the database was to export the data into a database-free schema, then import the data.
This plugin saved my life thousands of times: yaml_db.
this answer answered Nov 16 '09 at 9:27 Simone Carletti 130k 27 273 313 Great link! I'm going to use this for my next migration. – Matthew Rathbone Apr 4 '11 at 20:26
If you need to do it on the fly, via some sort of export method, you can just open a couple DB connections, one to your mysql db and one to your sqlite db, map the fields appropriately, and insert to your sqlite instance.
If you don't have to do it on the fly, there is this page.
this answer answered Nov 14 '09 at 21:10 Myles 12.7k 3 18 31
If you just want to move your data and schema from one to the other, this shouldn't be too hard, although if you are using one of the dark corners of mySQL, things might get hairier. Basically, you should dump your mySql database to some sort of file (there are a ton of ways to do this, for example from the command line or from something like phpmyAdmin) and then, if memory serves (it's been a while since I last did this stuff), do something like this:
sqlite3 <database name> ".import <export file name>"
Additionally, there is a script to automate this on the this page of the sqlite website, so you might see if it actually works.
this answer answered Nov 14 '09 at 21:21 Paul Wicks 21.1k 41 99 136
- 1Mysql 的按时间段分组查询
- 2Ruby on Rails，创建开发用的MYSQL数据库
- 3windows下配置Ruby on Rails和mysql驱动
- 5在Ruby on rails在使用SQLite