eralchemy icon indicating copy to clipboard operation
eralchemy copied to clipboard

reading relationships from Postgresql database

Open johny-b opened this issue 6 years ago • 4 comments

Hello,

I wanted to create .er file based on schema in Postgresql database. It works well for tables, but ignores relationships.

Example script

psql t1 -c "CREATE SCHEMA t1;
            CREATE TABLE  t1.parent(id INTEGER PRIMARY KEY);
            CREATE TABLE  t1.child (id INTEGER PRIMARY KEY,
                                   parent_id INTEGER REFERENCES t1.parent(id) NOT NULL)"
eralchemy -i 'postgresql+psycopg2:///t1' -s t1 -o t1.er
cat t1.er

yields output

[t1.parent]
    *id {label:"INTEGER"}
[t1.child]
    *id {label:"INTEGER"}
    parent_id {label:"INTEGER"}

ignoring FOREIGN KEY constraint. Is it intended?

I'm using PostgreSQL 9.6.10 on Ubuntu 18.04 and ERAlchemy version 1.2.10.

johny-b avatar Oct 04 '18 17:10 johny-b

Same problem for me. It ignores relations between tables when my input is an existing postgres instance.

ghost avatar Mar 04 '19 13:03 ghost

Same problem here!

renatolsromao avatar May 10 '19 19:05 renatolsromao

I have this issue as well.

lorarjohns avatar Nov 26 '20 00:11 lorarjohns

I could not reproduce this on my fork (https://github.com/maurerle/eralchemy2):

t1.er

[parent]
    *id {label:"INTEGER"}
[child]
    *id {label:"INTEGER"}
    parent_id {label:"INTEGER"}
parent ?--* child

t2

But this should also work with the latest eralchemy version (with sqlalchemy < 1.4)

maurerle avatar Oct 10 '22 10:10 maurerle