导入MySQL的转储文件的SQLite [英] Import MySQL dump file to SQLite

查看:227
本文介绍了导入MySQL的转储文件的SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的使用情况:
我有,我没有获得,既不始发文件MySQL数据库的服务器应用程序提供一个SQL转储文件。
在SQL转储文件是一个普通的,常见的基地SQL语法,如phpMyAdmin的产生的。
我下载这个文本文件导入Android设备。列只是类型'诠释'或'文字',而不是其他类型的。
我想然后将此文件导入到Android应用程序的SQLite数据库 - 基本上把文件读入一个流,然后执行一个接一个的SQL语句。
我的问题:是否有任何现有的类无论是在Android或可供的 - 你知识,我可以在Java / Android的使用并导入MySQL的转储文件直入SQLite的,所以做足了几个时间来制定一个解析器自己?
再次,它不是关于外部工具。
谢谢!

Here is my use case: I have an sql dump file provided by a server application that I don't have access to, neither to the MySQL database that originates the file. The sql dump file is an ordinary one, common base SQL syntax, as those generated by phpmyadmin. I download this text file into an Android device. The columns are just of type 'int' or 'text', not other types. I want then to import this file into the Android app's SQLite database - basically reading the file into a stream, then executing one-by-one the sql statements. My question: is there any existing class either in Android or available-of-your-knowledge that I can use in Java/Android and import the MySQL dump file straight into SQLite, so that to spare a couple of time to develop a parser myself? Again, it's not about external tools. Thanks!

推荐答案

由于我面对这个问题,我认为我的发现和解决办法是在别人的兴趣。
这里是:
     - MySQL是数据类型比SQLite的方面要丰富得多,所以没有详尽的转码实现成为可能。
     - 为了共同的数据类型,什么适合既作为内容重新presentation是'整'和'文字'。
     - 索引键具有不同的语法。
     - 总体而言,MySQL的转储文件需要太多解析出一个小的结果。

Because I faced this issue I think my findings and solution could be in the interest of others. Here it is: - MySQL is much richer in terms of data types than SQLite, so there is NO exhaustive transcoding implementation possible. - for the common data types, what fits both as content representation are 'integer' and 'text'. - the index key has a different syntax. - overall, the MySQL dump file would require too much parsing for a small result.

的解却是很简单的,即使我们没有获得始发 - MySQL的 - 数据库,如下:
     - 在你有完全控制权的另一个短暂的MySQL型数据库加载MySQL的转储。
     - 使用一个简单的(PHP)脚本读取然后写入MySQL表的内容到一个文本文件中。
     - 读取另一个脚本(Java的,于我而言,Android版)这个文本文件,并养活SQLite数据库表。假定SQLite的架构已经pviously创建$ P $。
这是基本的,但是,相信我,这是最适合这样的功能。
MySQL的和SQLite是绝对不一样的建筑!

THE SOLUTION however is very simple, even if we don't have access to the originating - MySQL - database, as following: - load the MySQL dump in another transient MySQL-type database where you have full control. - use a simple (PHP) script to read then write the content of the MySQL tables into a text file. - read this text file with another script (Java, in my case, for Android) and feed the SQLite database tables. It is assumed that the SQLite schema has been previously created. This is basic but, believe me, it is the most appropriate for such functionality. MySQL and SQLite are definitely not alike as construction!

这篇关于导入MySQL的转储文件的SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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