简体   繁体   English

在Android上将MySQL(mysqldump)转换为SQLite-是否有Windows Shell /命令行脚本?

[英]MySQL (mysqldump) to SQLite on Android - is there a Windows shell / command line script?

So, the question is almost entirely in the title: 因此,问题几乎完全在标题中:

I'm running an Android Virtual Machine on a Windows machine and I'm trying to transfer a MySQL database from a XAMPP-phpmyadmin server via a php script and mysqldump to create a new SQLite database on the Android machine. 我正在Windows计算机上运行Android虚拟机,并试图通过php脚本和mysqldump从XAMPP-phpmyadmin服务器传输MySQL数据库,以便在Android计算机上创建新的SQLite数据库。 When I run the script, like 当我运行脚本时,就像

$config = parse_ini_file('config.ini');
$dump = shell_exec('mysqldump --user=' . $config['username'] . ' --password=' . $config['password'] . ' --opt users');

I get the SQL dump, which I could echo and receive as a string in Android (I could also write it to a file). 我得到了SQL转储,我可以在Android中将其作为字符串进行回显和接收(也可以将其写入文件中)。 But I get the sweats when I think about extracting all the SQL syntax from the output. 但是,当我考虑从输出中提取所有SQL语法时,我会冒汗。

So, isn't there a nice little command line script that would do that for me, or any other more convenient way? 因此,是不是有一个不错的命令行脚本可以帮我做到这一点,或者没有其他更便捷的方法吗?

EDIT: For clarification: The script should be able to extract just the SQL syntax from the mysqldump output (there's a lot of non-SQL output in there) so I can use the string for an execSQL in Android. 编辑:为了澄清:该脚本应该能够从mysqldump输出中提取SQL语法(那里有很多非SQL输出),因此我可以在Android中使用该字符串作为execSQL。 I was just wondering: This must have been done before, I don't want to start from primordial ooze here. 我只是在想:这一定是以前完成的,我不想从这里的原始渗入开始。

EDIT 2: StackOverflow Question Convert MySQL to SQLite links to this page containing mysql2sqlite, which I could use with CygWin to convert; 编辑2:StackOverflow的问题转换到MySQL的SQLite的链接, 包含mysql2sqlite,我可以用CygWin的使用转换页面; but I can't do it all in a php script, as CygWin can't be used from Windows command line with mysql2sqlite and the dump file as a parameter. 但是我无法在php脚本中全部完成操作,因为无法从Windows命令行使用mysql2sqlite和转储文件作为参数来使用CygWin。 Right? 对?

You can import the mysqldump directly from SQLLite on Android if you're exporting it in the .sql format and adding options for recreating tables etc. 如果您以.sql格式导出mysqldump并添加用于重新创建表格的选项,则可以直接从Android上的SQLLite导入mysqldump。

No need to worry about the non-SQL syntax in the file, as it should be commented out. 无需担心文件中的非SQL语法,因为应该将其注释掉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM