0

I have looked for an answer to this question, but very was able to find very little. I want to extract the names of the tables, references between them, column names so I can graphically visualize that information. I need to this in a Django project.

Since I am a newbie to python I would like to know if there is some kind of API to do this type of thing.

Edit

I have created a model which consists Node, Attribute and Link. Node has attributes, while Link has fields parent_node and child_node. What I want is to connect to a database, read the metadata by which I mean: Table names, Column names and Foreign key constraints. Then I could properly put this data in the model I have created.

Neven Jovic
  • 177
  • 1
  • 2
  • 8
  • It is not really clear to me what you want. You want to visualize *foreign key* constraints? – Willem Van Onsem Jun 25 '18 at 13:36
  • I have created a model which consists Node, Attribute and Link. Node has attributes, while Link has fields parent_node and child_node. What I want is to connect to a database, read the metadata by which I mean: Table names, Column names and Foreign key constraints. Then I could properly put this data in the model I have created. Hope it is clearer now. – Neven Jovic Jun 25 '18 at 14:00

1 Answers1

0

You can use inspectdbcommand, with this django reads your database and create models for each table and if your database has relations you get also in django. You can see more info here.

python manage.py inspectdb
Ramiro Uvalle
  • 241
  • 1
  • 8
  • This doesn't exactly help me since it creates a model, what I need is basically string table and column names and information about which table references another table through the foreign key constraint. – Neven Jovic Jun 25 '18 at 14:08