you can work with multiple sessions and their objects simultaneously, with the 
provision that you don't add() an object from one session directly into the 
other one, without detaching it from the original session first.  to transfer 
the state of an object from one session to another without detaching it, use 
the session.merge() method.

more important is that when you work with these sessions, the sessions are not 
being simultaneously accessed by other concurrent tasks such as those in other 
threads, greenlets or async coroutines.  if the two sessions are local to the 
current task/thread/whatever, just keep track of which objects are from which 
and it will be fine.

On Wed, Apr 20, 2022, at 11:28 AM, Jason Hoppes wrote:
> I have an object that adds a user. I have another Object that gets cipher 
> information for that user's password. Each one having their own session. 
> Could I call the object that gets the cipher with a separate session with the 
> session that I add the user? Effectively it does a lookup using an inner 
> session.
> 
> Thanks in advance for your help.
> 
> - Jason
> 
> 
> -- 
> SQLAlchemy - 
> The Python SQL Toolkit and Object Relational Mapper
>  
> http://www.sqlalchemy.org/
>  
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> --- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/dea3c02c-1dce-4496-9b6d-11b6a7b0bafbn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/dea3c02c-1dce-4496-9b6d-11b6a7b0bafbn%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/7520dc40-224f-4883-bb32-ee0e3c0f9161%40www.fastmail.com.

Reply via email to