I know my question is very weird, but Have you ever tried the same SQL
string in the firebird console?


2013/4/29 Werner <[email protected]>

> On 29/04/2013 13:29, Werner wrote:
>
>> Hi,
>>
>> I am using the above to set the user language and I am sure this worked
>> for me, but it doesn't any more, in the mean time I upgraded to 0.8.1 (was
>> on 0.7.8) and I wonder where things changed.
>>
>> In a simple test like this it still works:
>>
>> session.execute("select rdb$set_context('USER_SESSION'**, 'LANGUAGE_ID',
>> 3)from rdb$database").fetchone()
>> session.commit()
>> result = session.query(db.Drinktype_LV)
>> for item in result:
>>     print item.name, item.language.name
>>
>> I get the correct item and language name values back.
>>
>> But when I try this in my application the context goes away and I am not
>> sure if this is SA doing this or Firebird.
>>
>> 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
>>             x = wx.GetApp().ds.execute(**setcont).fetchone()
>>             y = wx.GetApp().ds.execute(**getcont).fetchone()
>>             assert y[0] == 
>> str(self.loggedInUser.**language.id<http://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
>>     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<http://app.loggedInUser.language.id>
>> )
>>
>> Here the assert fails as the fetch returns None as if the context was not
>> set.
>>
>> the "print app.ds" both show:
>> <sqlalchemy.orm.session.**SessionMaker object at 0x06D41C90>
>>
>> app.ds is created with:
>> maker = sao.sessionmaker(autoflush=**True, autocommit=False,
>>                          expire_on_commit=True)
>> DBSession = sao.scoped_session(maker)
>>
>> app.ds = DBSession() # just checked again that I do this only in one
>> place of my code
>>
>> Anyone has a hint on where I am going wrong with all this?
>>
>> Werner
>>
>>  I added:
> print wx.GetApp().ds.execute("select current_connection from
> rdb$database").fetchone()
>
> just after the two other print statements and they both show the same
> connection number on each run.
>
> I guess this points the finger at Firebird SQL, no?
>
>
> Werner
>
> --
> 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 
> sqlalchemy+unsubscribe@**googlegroups.com<sqlalchemy%[email protected]>
> .
> To post to this group, send email to [email protected].
> Visit this group at 
> http://groups.google.com/**group/sqlalchemy?hl=en<http://groups.google.com/group/sqlalchemy?hl=en>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>


-- 
*Mauricio de Abreu Antunes*
Mobile: (51)930-74-525
Skype: mauricio.abreua

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to