I have the same problem with the snippet hereafter:
from elixir import *
class tt(Entity):
using_options(tablename = 'tt')
d = Field(Integer, primary_key = True)
setup_all()
metadata.bind = 'mysql://localhost/test'
while True:
a = tt.query.filter(None)
for x in a:
print x.d
raw_input('')
a = None
session.expire_all()
Once inserted new records in the table tt by using the command-line
mysql client (and committed), pressing return to loop once shows the
very same set of records, without the newly inserted ones.
On the other hand, note that I found out that moving the metadata.bind
assignment into the while loop does the job. But that means to
reconnect to the engine over and over, which is quite ugly:
from elixir import *
class tt(Entity):
using_options(tablename = 'tt')
d = Field(Integer, primary_key = True)
setup_all()
while True:
metadata.bind = 'mysql://localhost/test'
a = tt.query.filter(None)
for x in a:
print x.d
raw_input('')
Does anyone have a cleaner solution?
Fabien.
On Dec 20, 5:12 pm, DavidG <[email protected]> wrote:
> Thank you for your response. I am issuing a new query, that is not
> returning updated data.
>
> Thanks, David
>
> On Dec 20, 5:39 am, Gaetan de Menten <[email protected]> wrote:
>
> > On Sat, Dec 19, 2009 at 16:17, DavidG <[email protected]> wrote:
> > > I am having a problem where I have an application that uses elixir on
> > > top of a database that can be updated by another application. If i
> > > don't do a full restart of the first application it does not seem to
> > > pickup the database changes.
>
> > > I have tried all of the following:
> > > session.remove()
> > > session.expunge_all()
> > > session.close_all()
> > > session.expire_all()
> > > session.clear()
> > > session.flush()
> > > session.close()
>
> > > I have also tried to reload the module that is being called...
>
> > Do you know that the in-memory objects (within the session or not) are
> > never automatically updated with the changes in the database? You have
> > to do session.query or session.merge.
>
> > Other than that, does the other application commit its changes?
>
> > Hope it helps,
> > --
> > Gaëtan de Mentenhttp://openhex.org
--
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en.