Hi, I am quite new to sqlalchemy. I am trying to implement a many-to-one relationship between classes in different modules. I was able to get this to work when classes are inside the same module however when I put the classes in different modules I get import errors. I made sure I used strings while referring to the keys. I was wondering if someone can give me some advice. lattice_definition.py:
from sqlalchemy.orm import sessionmaker, relationship from setuptools.tests.test_resources import Metadata from sqlalchemy.orm import relationship,backref from sqlalchemy import ForeignKey from sqlalchemy.schema import PrimaryKeyConstraint from Irmis.model_definition import model class lattice(Base): __tablename__='lattice' lattice_id= Column(Integer, primary_key=True) machine_mode_id=Column(Integer,ForeignKey('machine_mode.machine_mode_id')) model_geometry_id=Column(Integer,ForeignKey('model_geometry.model_geometry_id')) model_line_id=Column(Integer,ForeignKey('model_line.model_line_id')) gold_lattices=relationship("gold_lattice") elements=relationship("element") model_definition.py: from sqlalchemy.orm import relationship,backref from sqlalchemy import ForeignKey from sqlalchemy.schema import PrimaryKeyConstraint from Irmis.lattice_definition import Base from Irmis.lattice_definition import lattice class model(Base): __tablename__='model' model_id=Column(Integer,primary_key=True) lattice_id=Column(Integer,ForeignKey("lattice.lattice_id")) Thanks, --Arman -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.