Book a Demo

Author Topic: Create tables from MySql  (Read 5459 times)

rmartinezb

  • EA User
  • **
  • Posts: 44
  • Karma: +1/-0
    • View Profile
Create tables from MySql
« on: May 17, 2016, 09:10:01 pm »
Hi!

I'm programming an addin in C# (only for learning purposes) that connects with a MySql database. I do a "SHOW COLUMS FROM myTable" query and im trying to draw in EA the table with the obtained data.

Has EA SDK any tool to draw the table using this data?
For example: EA.Element newElement = TheQueryThatReturnTheTableData
I saw a tool in EA that draws the schema of a database, but i have to do this programming in the addin.

I know that i can create a table, creating the element, the atributes, and methods, but if exist a easier way i would like to know it.

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Create tables from MySql
« Reply #1 on: May 17, 2016, 11:24:45 pm »
Hi,

as far as I know you have to implement it with your Addin. There is no simple API from sql select to EA elements, attributes,...

Instead of your Addin you may use the Database Builder to create EA objects of your Database. You may investigate is e.g. Geerts Excel importer.

Helmut

Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create tables from MySql
« Reply #2 on: May 17, 2016, 11:54:29 pm »
I'd also suggest to use Package/Database Engineering/Import... to do the import automatically. That works rather nice and there is no real need to re-invent the wheel here.

q.

rmartinezb

  • EA User
  • **
  • Posts: 44
  • Karma: +1/-0
    • View Profile
Re: Create tables from MySql
« Reply #3 on: May 18, 2016, 12:24:21 am »
Yes, i know that I'm re-inventing the wheel, but I'm doing this only for practice and understad how the add-in creation works.
I don't have a real task, i'm only learning about the automation interface and the EA programming.

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
Re: Create tables from MySql
« Reply #4 on: May 18, 2016, 03:20:50 am »
In principle you can do that, but not as simple as you have mentioned. If you want to re-invent what is already there you need to have to analyze your table structure and build ea classes and attributes on that.
I recommend searching for some running small plug-in examples rather than starting with your db approach.

E.g.
https://bellekens.com/2011/01/29/tutorial-create-your-first-c-enterprise-architect-addin-in-10-minutes/
Best regards,

Peter Heintz

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create tables from MySql
« Reply #5 on: May 18, 2016, 01:36:38 pm »
Unfortunately there are no shortcuts.

The only thing you can do is use the work of others.
I've created a framework for my add-ins so I could re-use some of the code.
This framework (and all the add-ins that are based on it) are open source and on github https://github.com/GeertBellekens
I wrote a small article explaining how this works as well: How to use the Enterprise Architect Add-in Framework

Geert