Question

I have a .mwb database but I need to load it in my phpmyadmin (I have already Wamp installed). I tried to install mysql workbench but it detected another mysql and I canceled the instalation.

how can I convert it to take the .sql file of this .mwb?

Thank you!

Was it helpful?

Solution

A Workbench model is a compressed file (in other words, a renamed ZIP file). You should be able to open it with any decent archiver. Inside, there's an XML file. I don't know if the format is documented but it looks quite straightforward:

<value type="object" struct-name="db.mysql.Table" id="{DF899AC1-6CAA-42A8-A584-A663E17596E9}" struct-checksum="0x1a403946">
  <value type="string" key="avgRowLength"></value>
  <value type="int" key="checksum">0</value>
  <value _ptr_="0971BA88" type="list" content-type="object" content-struct-name="db.mysql.Column" key="columns">
    <value type="object" struct-name="db.mysql.Column" id="{A742D230-C0CE-48C7-88E0-B5DB74409FE4}" struct-checksum="0x783b5183">
      <value type="int" key="autoIncrement">1</value>
      <value type="string" key="characterSetName"></value>
      <value _ptr_="0971BF08" type="list" content-type="object" content-struct-name="db.CheckConstraint" key="checks"/>
      <value type="string" key="collationName"></value>
      <value type="string" key="datatypeExplicitParams"></value>
      <value type="string" key="defaultValue"></value>
      <value type="int" key="defaultValueIsNull">0</value>
      <value _ptr_="0971BF98" type="list" content-type="string" key="flags">
        <value type="string">UNSIGNED</value>
      </value>
      <value type="int" key="isNotNull">1</value>
      <value type="int" key="length">-1</value>
      <value type="string" key="name">invoice_id</value>
      <value type="int" key="precision">10</value>
      <value type="int" key="scale">-1</value>
      <link type="object" struct-name="db.SimpleDatatype" key="simpleType">com.mysql.rdbms.mysql.datatype.int</link>
      <value type="string" key="comment"></value>
      <value type="string" key="oldName">invoice_id</value>
      <link type="object" struct-name="GrtObject" key="owner">{DF899AC1-6CAA-42A8-A584-A663E17596E9}</link>

So you basically need to spend a few days writing a script that parses XML and composes SQL code.

(Honestly, I think it'd be a waste of time, considering that the original Workbench is free and cross-platform.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top