I'd like to join query with calendarID across the tables to see if given the (user) ID in channel table, is the channelID of calendarID empty? if so, write to it.
Models.py:
class User(db.Model):
id = Column(Integer, primary_key=True)
calendarID = Column(String(100), unique=False, nullable = True)
Channel = relationship('Channel', backref='owner')
class Channel(db.Model):
id = Column(Integer, primary_key=True)
calendarID = Column(String(100), unique=False, nullable = True)
channelID = Column(String(100), unique=False, nullable = True)
owner_id = Column(Integer, ForeignKey('user.id'))
Routes.py:
def activateChannel(id):
"""
reactivates the channel for notification to be received
"""
import random
import string
breakpoint()
user = db.session.query(User, Channel).filter(User.id==Channel.id).filter(User.calendarID==Channel.calendarID)
if user.channelID is None:
user.channelID = ''
else:
pass
However, I get:
*** AttributeError: 'User' object has no attribute 'channelID'