Multiple Database Connection

17 views
Skip to first unread message

Mustafa Demiraslan

unread,
Mar 22, 2022, 9:41:50 AM3/22/22
to sqlalchemy
Hi team,
I am using 3 database engines at the same time, 1(include 1 database) + 1(include 1 database) + 1(include 18 database). I use the database containing 18 databases by switching the bindings. I connect to database using sessions with session_maker for each engine. During the load test, I am stuck on the max_connection limit for the part containing 18 databases. Do you think the right approach is to create a separate engine for each database(1+1+18 engine) or is it a single engine multiple binding? I would be very happy if you express your thoughts.

Regards,

Mustafa

Mike Bayer

unread,
Mar 22, 2022, 10:12:50 AM3/22/22
to noreply-spamdigest via sqlalchemy
for one engine with 18 databases, what is "switching the bindings"  ?  do you mean you call "USE <database>" on the connection ?  

creating 18 separate engines would not be that big a deal if that's what works best for the code, no issue doing that.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
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+...@googlegroups.com.

Mustafa Demiraslan

unread,
Mar 22, 2022, 10:27:06 AM3/22/22
to sqlal...@googlegroups.com
Current structure is like this:

image.png

I can't manage pooling for green colored databases. 


Mike Bayer <mik...@zzzcomputing.com>, 22 Mar 2022 Sal, 17:12 tarihinde şunu yazdı:

Mike Bayer

unread,
Mar 22, 2022, 11:27:46 AM3/22/22
to noreply-spamdigest via sqlalchemy
a single Engine only points to one database URL at a time.   so to that extent, as an Engine assumes there's a "default database" when it connects, any concept of multiple "databases" beneath that is not something the Engine is aware of.   

PostgreSQL itself has no "USE" command, so if you have a connection to a PostgreSQL database, that's the one you're talking to, so given this architecture you would definitely need to create an individual Engine per database.

OTOH if these are actually PostgreSQL **schemas** and not databases, that would be something entirely different, but you haven't specified this.

Mustafa Demiraslan

unread,
Mar 22, 2022, 11:38:02 AM3/22/22
to sqlal...@googlegroups.com
Yes all of these are a database not schema.
Thank you for response.

Mike Bayer <mik...@zzzcomputing.com>, 22 Mar 2022 Sal, 18:27 tarihinde şunu yazdı:
Reply all
Reply to author
Forward
0 new messages