Skip to content

Problems using automap_base with DB2-s SAMPLE DB #20

@boromil

Description

@boromil

Using the official docker form IBM for DB2 10.5.5:

https://hub.docker.com/r/ibmcom/db2express-c/

docker run -it -p 50000:50000 -e DB2INST1_PASSWORD=mypass -e LICENSE=accept ibmcom/db2express-c:latest bash

# create db
su - db2inst1
db2start
db2sampl

python requirements:

sqlalchemy==1.0.17
ibm-db==2.0.5.1
ibm_db_sa==0.3.2

(btw. tried this with the newest versions also - same result)

OS: Ubuntu 14.04 64bit

Doing:

from sqlalchemy.ext.automap import automap_base
from sqlalchemy import create_engine

Base = automap_base()
engine = create_engine("db2://db2inst1:mypass@172.18.0.1:50000/SAMPLE")
Base.prepare(engine, reflect=True)

raises:

Traceback (most recent call last):
  File "db2_automap.py", line 8, in <module>
    Base.prepare(engine, reflect=True)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/automap.py", line 777, in prepare
    generate_relationship)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/automap.py", line 899, in _relationships_for_fks
    nullable = False not in set([fk.parent.nullable for fk in fks])
AttributeError: 'NoneType' object has no attribute 'nullable'

seems that some fk-s have incorrect parent and column attributes

this issue was reported to SQLAlchemy-s team, but this place is more appropriate for it

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions