Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
# -*- coding: utf-8 -*-
from sqlalchemy import create_engine, Integer, Column, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
engine = create_engine('sqlite://')
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
a_id = Column(Integer, ForeignKey(A.id))
a = relationship(A, backref='bbb')
print B.a
try:
print A.bbb
except AttributeError:
print "Yep, AttributeError"
else:
raise Exception("The bug is fixed!")
A.__mapper__.relationships
print "Now it is loaded: ", A.bbb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.