关于从 mysql 源填充 sqlite 数据库的 ruby​​ 解决方案的任何建议 [英] Any suggestions for a ruby solution for populating a sqlite database from a mysql source

查看:46
本文介绍了关于从 mysql 源填充 sqlite 数据库的 ruby​​ 解决方案的任何建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 MySQL 的 Rails 应用程序.应用程序需要填充要从主 mysql 数据库分发到客户端应用程序的 sqlite 数据库.sqlite 数据库的架构将与 mysql 数据库非常相似,但不完全相同.sqlite 数据库将填充主 mysql 数据库中存储的模式和数据的子集.数据子集将由 http 请求中传递的参数确定.这不是作为维护操作,而是将 mysql db 的子集作为 sqlite db 交付给客户端应用程序.

I have a Rails application that uses MySQL. The application needs to populate sqlite databases to be distributed to client applications from the master mysql database. The schema for the sqlite database will be very similar to the mysql database, but not identical. The sqlite databases will be populated with a subset of the schema and data stored in the master mysql database. The data subset will be determined by parameters passed in the http request. This is not intended as a maintenance operation, but a delivery of a subset of the mysql db to client applications as a sqlite db.

我想尝试修改taps或使用 sequel 编写金属应用程序以连接到两个数据库以传输数据.

I was thinking of trying to modify taps or writing a metal app using sequel to connect to both databases to transfer the data.

还有其他建议吗?

推荐答案

免责声明:我是 Sequel 的维护者.

Disclaimer: I'm the Sequel maintainer.

续集可能是最简单的方法.bin/sequel 工具可以将 MySQL 数据库复制到 SQLite 数据库,因此如果您查看源代码 (http://github.com/jeremyevans/sequel/blob/205d8a04842c143736de76d645a2a955a1ca641f/bin/sequel),您可以通过 Sequel 了解如何做到这一点.

Sequel would probably be the easiest way to do this. The bin/sequel tool can copy a MySQL database to an SQLite database, so if you look at the source code to that (http://github.com/jeremyevans/sequel/blob/205d8a04842c143736de76d645a2a955a1ca641f/bin/sequel), you can get an idea of how to do this with Sequel.

由于事物的构造方式,最简单的方法可能是直接复制架构,然后删除不需要的列.或者,我只需编写代码来创建我想要的 SQLite 数据库架构.

Because of the way things are constructed, it's probably easiest to just copy the schema directly, and then drop unneeded columns. Alternatively, I'd just write the code to create the SQLite database schema I wanted.

复制数据的代码可能会使用 bin/sequel 中的修改版本.

The code to copy the data can probably use a modified version of what's in bin/sequel.

这篇关于关于从 mysql 源填充 sqlite 数据库的 ruby​​ 解决方案的任何建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆