Toad World® Forums

Reverse Engineer a database from the command line.

Hi,

I am attempting to take a database on a SQL server instance on my machine and, from the command line, have TDM create a new model, reverse engineer the DB into the new model, and save out the model file.

I have been able to launch toad with a blank model but I have not yet found a way to execute the appropriate scripts to preform the Reverse engineering.

Any help is appriciated.

Thank you,

Dan

Hi,

you can find an example in the Help file. See attached screenshot.

Regadrs,

Vaclav

Thanks for pointing me in the right direction. I am having a little trouble with the example from the help file though. When I run the example, the script throws an error at the following line from the LoadPackagesByModelDefName, because MDef is null:

MDef.LoadPackages();

I’ve added some debugging statements and the GetObjectByName(AName) call is returning null when caled with AName = ‘Microsoft SQL Server 2008’

Am I using the wrong Model Definition name or do I have something else wron with my scripts?

Thanks again,

Dan

Hi,

I have several questions for you:

  1. What version of Toad Data Modeler do you use?

  2. What is the name of your stored alias (TDM 4.x) or connection (TDM 5) ?

(Please provide screenshot, if possible.)

  1. Did you install the software with all supported database platforms, please? (During installation you can choose database platforms. Ideally, install all items).

Thanks,

I have tried running this in Toad Data Modeler 4.3, as well as in version 5.0.5.31.

The Alias I created is called “DJE-alias1”. It connects to a DB on my local machine and is set to revese engineer the entire DB (Entities, Relationships, etc.)

Toad_Alias1.jpeg

I know that version 5.0.5 was installed with all the database platforms, and I believe that 4.3 was as well, though its been a while since I installed it.

The script that I am running from the scripting window in Toad 5.0.5 is attached. Please forgive the debuging message boxes.

Let me know if you need further detail of the Alias/Connection.

Thanks again,

Dan
ToadREScrpt.txt (3 KB)

Hi,

please use MS SQL Server 2008 instead of Microsoft SQL Server 2008. We used to use MS abbreviation in past and then changed the caption from MS to Microsoft.

Wrong:
var Model = RE(‘DJE-alias1’, App, ‘Microsoft SQL Server 2008’);
Correct:
var Model = RE(‘DJE-alias1’, App, ‘MS SQL Server 2008’);

To find out correct model def, do the following:

  1. Create new model for selected targret database.
  2. Enable Expert Mode in Settings.
  3. Click Expert Mode | Scripting Window
  4. Add your model to right side
  5. Run the following script

function main(){
Log.Information(Model.ModelDef.Name);
}

kom-modeldef.png

Result:

kom-modeldef-1.png

I hope it helps,

Vaclav,

I figured that it was something like that. After correcting that the script is working correctly.

Thank you very much for your help.

Dan

My pleasure :slight_smile: