Hi all,
I am using simple SQLALCHEMY implementation.
I have two classes Svc, Mani
class Svc(Base):
''' class to map 'service' table in database
'''
__tablename__ = 'svc'
__table_args__ = {'autoload': True}
manis = relationship('Mani')
What I found that upon issuing session.query(Svc).all()
only refreshes Svc (svctable) entries from the database, but the
manis collection
is queried only once (on first query ) and it is not refreshed every
time session.query(Svc)
is issued.
What should I set so that manis collection should issue query and refresh and
sync itself with database everytime it is accessed or atleast everytime
session.query(Svc).all is issued.
You can see in detail steps for the issue.
I have two different session connected to the database using two different
terminals.
-------------------------------
In terminal I
svcs = session.query(Svc).all()
svc1 = svcs[0]
(halt)
------------------------------
In terminal II
svcs = session.query(Svc).all()
svc1 = svcs[0]
for mani in svc1.manis:
print mani.name
(halt)
----------------------------------
In terminal I
(continue from previous state)
test_mani = Mani()
svc1.manis.append(test_mani)
session.commit()
# New test_mani is commited to DB
# Do the query
svcs = session.query(Svc).all()
svc1 = svcs[0]
for mani in svc1.manis:
print mani.name
# The new mani is printed
(halt)
--------------------------------
In terminal II
(continue from previous state)
requery
svcs = session.query(Svc).all()
svc1 = svcs[0]
for mani in svc1.manis:
print mani.name
# The newly added test_mani is not part of
# svc1.mani even after Svc is requried.
Thanks in advance for your guidance.
regards
Balaji
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.