Subject | RDB$SET/GET_CONTEXT problem |
---|---|
Author | Werner F. Bruhin |
Post date | 2013-04-29T11:50:10Z |
Hi,
I use Firebird SQL (2.5) and SQLAlchemy (0.8.1) with kinterbasdb and the
context setting is not retained.
I do this:
During the app init (wxPython) I do this:
setcont = "select rdb$set_context('USER_SESSION',
'LANGUAGE_ID', %s) \
from rdb$database" % self.loggedInUser.language.id
print wx.GetApp().ds.execute("select current_connection
from rdb$database").fetchone()
print wx.GetApp().ds
x = wx.GetApp().ds.execute(setcont).fetchone()
y = wx.GetApp().ds.execute(getcont).fetchone()
assert y[0] == str(self.loggedInUser.language.id)
wx.GetApp().ds.commit()
Fine so far, now I try to use it e.g. like this:
app = app_base.BaseApp(redirect=False)
print app.ds
print wx.GetApp().ds.execute("select current_connection from
rdb$database").fetchone()
getcont = "select rdb$get_context('USER_SESSION', 'LANGUAGE_ID') \
from rdb$database"
y = app.ds.execute(getcont).fetchone()
assert y[0] == str(app.loggedInUser.language.id)
Here the assert fails as the fetch returns None as if the context was
not set.
The two print statements within the app init and when I try to use it
give me the same SQLAlchemy session back and I get the same connection
number from the other print.
Anyone has an idea why context is not staying around?
Werner
I use Firebird SQL (2.5) and SQLAlchemy (0.8.1) with kinterbasdb and the
context setting is not retained.
I do this:
During the app init (wxPython) I do this:
setcont = "select rdb$set_context('USER_SESSION',
'LANGUAGE_ID', %s) \
from rdb$database" % self.loggedInUser.language.id
print wx.GetApp().ds.execute("select current_connection
from rdb$database").fetchone()
print wx.GetApp().ds
x = wx.GetApp().ds.execute(setcont).fetchone()
y = wx.GetApp().ds.execute(getcont).fetchone()
assert y[0] == str(self.loggedInUser.language.id)
wx.GetApp().ds.commit()
Fine so far, now I try to use it e.g. like this:
app = app_base.BaseApp(redirect=False)
print app.ds
print wx.GetApp().ds.execute("select current_connection from
rdb$database").fetchone()
getcont = "select rdb$get_context('USER_SESSION', 'LANGUAGE_ID') \
from rdb$database"
y = app.ds.execute(getcont).fetchone()
assert y[0] == str(app.loggedInUser.language.id)
Here the assert fails as the fetch returns None as if the context was
not set.
The two print statements within the app init and when I try to use it
give me the same SQLAlchemy session back and I get the same connection
number from the other print.
Anyone has an idea why context is not staying around?
Werner