Hi,

Before we talk about the read-replica, let's talk about the test suite as 
it is.  I have a sessionmaker in my test suite configured to use an 
external transaction.  Basically identical to this: 
https://docs.sqlalchemy.org/en/13/orm/session_transaction.html#joining-a-session-into-an-external-transaction-such-as-for-test-suites
 
.  This is great for performance and I have no complaints about it.

To integrate a "read-replica" in my test suite I'm very clever.  I just say 
"master = master_connection" and "slave = master_connection".  The test 
suite has no idea there is a read-replica at all.

Unfortunately, the coverage I get is not comprehensive.  Because a "slave" 
connection in this context could write to the database and cause errors in 
production.  So I need some way to differentiate the connections without 
breaking the external transaction.  Any thoughts on how I could do this?  
Any argument I can pass to the sessionmaker to make it read-only while 
still making the data in the transaction available to each?

Thanks!

-- 
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/a83a28d9-0982-4686-928e-a451f60ee791%40googlegroups.com.

Reply via email to