将 MySQL 转移到 SQLite

发布于 2024-08-09 16:47:24 字数 344 浏览 3 评论 0原文

我想开始在 iPhone 上使用 Core Date 和预先存在的 MySQL 数据库。将 MySQL 数据库转移到 SQLite 的最简单方法是什么?

我尝试过使用 SQLite Migrator,但我不知道在哪里可以找到 Mac (Snow Leopard) 的 ODBC 驱动程序。我发现 http://www.ch-werner.de/sqliteodbc/ 似乎有驱动程序,但它们适用于 Power PC。

如果有人能给我一个演练,或者告诉我最好的工具是什么,我将不胜感激。

谢谢。

I want to start using Core Date on iPhone with pre-existing MySQL databases. What's the easiest way to transfer a MySQL database to SQLite?

I've tried using SQLite Migrator, but I don't know where to find the ODBC drivers for Mac (Snow Leopard). I found http://www.ch-werner.de/sqliteodbc/ which seems to have drivers, but they are for Power PC.

If someone could give me a walkthrough, or tell me what the best tools for this are, I'd be grateful.

Thanks.

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

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

发布评论

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

评论(7

海螺姑娘 2024-08-16 16:47:24

也许最简单的方法是使用 mysqldump 转储原始 SQL从 MySQL 数据库写入文本文件,然后使用 sqlite3_exec() 函数来执行该文件SQL 以便填充 SQLite 数据库。

Perhaps the simplest would be to use mysqldump to dump the raw SQL from your MySQL database into a text file and then use the sqlite3_exec() function to execute that SQL in order to populate the SQLite database.

耳根太软 2024-08-16 16:47:24

您看过这个 Perl 脚本吗?我还没有使用过它 - 只是快速搜索了 mysql to sqlite 迁移,它就弹出了。


编辑(在您回复我的评论后):

反向处理在这里

如果您要重复执行此操作并且要发生数据结构更改,也许您最好使用 Django 之类的东西 (尽管以一种非常黑客的方式)。有了它我会:

# This three lines are done once
django-admin.py startproject mymigrationproject
cd mymigrationproject
./manage.py startapp migration

# The following lines you repeat each time you want to migrate the data
edit settings.py and make the changes to connect to MySQL
./manage.py inspectdb > ./migration/models.py
edit ./migration/models.py to reorder tables (tables in which other tables depend on top)
mkdir fixtures
./manage.py dumpdata migration > ./fixtures/data.json
edit settings.py and make the changes to connect to SQLite
./manage.py syncdb
./manage.py loaddata ./fixtures.data.json

Have you looked at this Perl script? I haven't used it - just did a quick search for mysql to sqlite migration and it popped right up.


Edit (after you replied to my comment):

The reverse direction is dealt with here.

If you are going to do it repeatedly and if data structure changes are to happen, maybe you would be better off using something like Django (albeit in a very hackish way). With it I would:

# This three lines are done once
django-admin.py startproject mymigrationproject
cd mymigrationproject
./manage.py startapp migration

# The following lines you repeat each time you want to migrate the data
edit settings.py and make the changes to connect to MySQL
./manage.py inspectdb > ./migration/models.py
edit ./migration/models.py to reorder tables (tables in which other tables depend on top)
mkdir fixtures
./manage.py dumpdata migration > ./fixtures/data.json
edit settings.py and make the changes to connect to SQLite
./manage.py syncdb
./manage.py loaddata ./fixtures.data.json
时光礼记 2024-08-16 16:47:24

以下是转换器列表:


An alternative method that would work nicely but is rarely mentioned is: use a ORM class that abstracts the specific database differences away for you. e.g. you get these in PHP (RedBean), Python (Django's ORM layer, Storm, SqlAlchemy), Ruby on Rails ( ActiveRecord), Cocoa (CoreData)

即你可以这样做:

  1. 使用 ORM 类从源数据库加载数据。
  2. 将数据存储在内存中或序列化到磁盘。
  3. 使用 ORM 类将数据存储到源数据库中。

Here is a list of converters:


An alternative method that would work nicely but is rarely mentioned is: use a ORM class that abstracts the specific database differences away for you. e.g. you get these in PHP (RedBean), Python (Django's ORM layer, Storm, SqlAlchemy), Ruby on Rails ( ActiveRecord), Cocoa (CoreData)

i.e. you could do this:

  1. Load data from source database using the ORM class.
  2. Store data in memory or serialize to disk.
  3. Store data into source database using the ORM class.
柳若烟 2024-08-16 16:47:24

You can use a trial from http://www.sqlmaestro.com/products/sqlite/datawizard/

It is completely functional for 30 days.

暮倦 2024-08-16 16:47:24

您可以从 Actual Technologies 获取适用于 Mac OS X 的 ODBC 驱动程序。

http://www.actualtech.com/

要连接到 MySQL,您需要用于开源数据库的 ODBC 驱动程序:

http://www.actualtech.com/product_opensourcedatabases.php

(免责声明:我是SQLite 迁移器的作者)

You can get ODBC drivers for Mac OS X from Actual Technologies.

http://www.actualtech.com/

To connect to MySQL you need their ODBC Driver for Open Source Databases:

http://www.actualtech.com/product_opensourcedatabases.php

(Disclaimer: I am the author of SQLite Migrator)

撕心裂肺的伤痛 2024-08-16 16:47:24

有一种免费的 ETL 产品可用于将数据从一个数据库迁移到另一个数据库。看看:http://www.talend.com/index.php

祝你好运!

There is a free ETL product that can be used to migrate data from one db to another. Have a look: http://www.talend.com/index.php

Good luck!

瘫痪情歌 2024-08-16 16:47:24

为了进行转换,我最终使用了 来自 Actual Access 的 ODBC。我想我将它与 SQLite Migrator 结合使用。我从来不喜欢这种方式,尽管它总是很笨重。价格也很贵,这两个软件最终花费了大约 80 美元。

如果我必须再次这样做,我会购买 SQLabs 的 SQLiteConverter 。我使用他们的SQLite Manager,虽然它有很多界面问题,但对于数据库软件来说还不错。

http://www.sqlabs.net/sqliteconverter.php

To do my conversions, I ended up using an ODBC from Actual Access. I think I used it in combination with SQLite Migrator. I never liked this way though it was always clunky. Expensive too, it ended up costing about $80 for those two pieces of software.

If I had to do this again, I'd buy SQLiteConverter by SQLabs. I use their SQLite Manager, and although it has a lot of interface problems, for database software it's not bad.

http://www.sqlabs.net/sqliteconverter.php

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