0

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. 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). But I get the sweats when I think about extracting all the SQL syntax from the output.

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. 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; 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. Right?

Community
  • 1
  • 1
cirko
  • 211
  • 2
  • 11
  • The way you worded this is confusing. Can you clarify how the Android device will be receiving the SQL dump? – Alex W Jun 10 '15 at 14:46
  • @AlexW OK, tried to clarify it... thought of starting off with echoing the output and receiving it as String, then using it for execSQL on a new SQLite database. – cirko Jun 10 '15 at 14:57
  • @AlexW although technically a workaround, I'd also accept that as an answer :) – cirko Jun 11 '15 at 09:25
  • Awesome. Glad you got it figured out! Just added it as an answer. – Alex W Jun 11 '15 at 13:21

1 Answers1

1

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.

No need to worry about the non-SQL syntax in the file, as it should be commented out.

Community
  • 1
  • 1
Alex W
  • 33,401
  • 9
  • 92
  • 97