Re: [sqlalchemy] orm.relationship() with dynamic part ?

2018-04-05 Thread Mike Bayer
you can do a bindparam with a callable, which I *think* should work here: ContentTranslation.language_id == bindparam(None, callable_=lambda: get_current_request().locale_name) you want to set bake_queries=False on this relationship(). if it doesn't work, there's other ways to do this too.

[sqlalchemy] orm.relationship() with dynamic part ?

2018-04-05 Thread Julien Cigar
Hello, I wondered what would be the "best" way to achieve something like: https://gist.github.com/silenius/f4f98acc372e228093298002c0736894#file-foo-py-L5 ? With "get_current_request().locale_name" replaced by "en" I'm getting something like

Re: [sqlalchemy] Inherit foreign key to a dynamic table based on inherited column value

2018-04-05 Thread Johnathan Norton
I wasnt looking to use the monster,race,foliage, and fauna classes as mixins for the character ones. There's not a monster, or fauna stat that i want to add on to a character object. Didnt realize this is what I'm trying to do until you asked the right questions. I guess I'm trying to make it

Re: [sqlalchemy] Inherit foreign key to a dynamic table based on inherited column value

2018-04-05 Thread Mike Bayer
when you have CharacterEntity, would there also be MonsterCharacterEntity, FaunaCharacterEntity, etc. ? if you had "Monster", "Fauna", "Race", "Foliage" mixins that are applied to the LivingEntity hierarchy that would be a place to hold your "species_lookup" relationship. What is the base of the

[sqlalchemy] Inherit foreign key to a dynamic table based on inherited column value

2018-04-05 Thread Johnathan Norton
Disclaimer: I'm very new at this. Only been learning databases for a couple weeks, and been working with python for about a month and 1/2. I did do several searches, phrasing things differently, but I can't seem to find my answer. I'm trying to build a overly complex DnD database and cmdline

Re: [sqlalchemy] Is it safe to re-use a closed session?

2018-04-05 Thread Mike Bayer
On Thu, Apr 5, 2018 at 7:12 AM, 'Brian Candler' via sqlalchemy wrote: > The documentation doesn't seem to be 100% clear on this point: if you > close() a session, can you continue to use it as if it were a fresh session? > (Unlike say a closed filehandle) > > In other

[sqlalchemy] Is it safe to re-use a closed session?

2018-04-05 Thread 'Brian Candler' via sqlalchemy
The documentation doesn't seem to be 100% clear on this point: if you close() a session, can you continue to use it as if it were a fresh session? (Unlike say a closed filehandle) In other words, in a non-threaded application, is this a