3

I'm coding a library to compare two MySQL databases.

Sources can be a SQL string, SQL file or a MySQL database connection.

Use regular expressions to parse tables/alter/indexes form sources is terrible and with a lot of possible syntaxes.

I have the script to generate a SQL string from any source, and now I need to import this SQL into a temporal database, to launch the DESCRIBE table and parse this text. Is a lot of more easy and clean than originals sources.

There are any way to create a memory/temporal MySQL database from PHP PDO without user and password credentials?

I have same script to SQLite, that allow to create memory connections with:

$db1 = new PDO('sqlite::memory:');

$db1->exec($sql);

$tables = [];

foreach ($db1->query('.tables') as $table) {
    $q = $db1->prepare('.schema ?');
    $q->execute([$table]);

    $tables[$table] = $q->fetchAll();
}

There is a lot of more easy to compare databases.

How can I do this with MySQL?

Thanks :)

Lito
  • 1,262
  • 2
  • 17
  • 25
  • https://dev.mysql.com/doc/refman/5.6/en/memory-storage-engine.html – Mark Baker Mar 31 '15 at 23:22
  • Yes, I know, I have the script with SQLite code and now I need to do something similar with MySQL. – Lito Mar 31 '15 at 23:22
  • 1
    Thanks @MarkBaker, to create memory tables I need an existing database previously. I need a memory database, not only tables. Anyway to create tables in memory I need to change the original SQL code and then I will can't compare. – Lito Mar 31 '15 at 23:27

0 Answers0