Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# -*- 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 = relationship(A, backref='bbb')
print B.a
print A.bbb
except AttributeError:
print "Yep, AttributeError"
raise Exception("The bug is fixed!")
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