[sqlalchemy] Conditional Insertion of Single Row with Bind Parameters

2022-03-22 Thread mkmo...@gmail.com
I would like to do a conditional insert of a a single row. This is often useful in a CRUD app for checking permissions and inserting in a single database call: INSERT INTO project (name, user_id) SELECT :name, :user_id WHERE EXISTS ( SELECT 1 FROM users WHERE id = :user_id

Re: [sqlalchemy] do_connect listener called couple of times

2022-03-22 Thread Srinu Chp
Hello Simon, I tried your suggestion as POC: def setup_event_handlers(engine): @event.listens_for(engine, 'do_connect') def receive_do_connect(dialect, conn_rec, cargs, cparams): print("inside do_connect") print('password %s' % cparams['password']) try: print("inside try") return

Re: [sqlalchemy] do_connect listener called couple of times

2022-03-22 Thread Simon King
I don't know anything about Airflow. Are you sure that each of these tasks is running inside the same Python interpreter/process? I see Airflow can distribute tasks among workers: https://airflow.apache.org/docs/apache-airflow/stable/executor/index.html This sounds like a problem that is going

Re: [sqlalchemy] Multiple Database Connection

2022-03-22 Thread Mike Bayer
for one engine with 18 databases, what is "switching the bindings" ? do you mean you call "USE " 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. On Tue, Mar 22, 2022, at 9:41 AM, Mustafa Demiraslan

Re: [sqlalchemy] Multiple Database Connection

2022-03-22 Thread Mustafa Demiraslan
Current structure is like this: [image: image.png] I can't manage pooling for green colored databases. Mike Bayer , 22 Mar 2022 Sal, 17:12 tarihinde şunu yazdı: > for one engine with 18 databases, what is "switching the bindings" ? do > you mean you call "USE " on the connection ? > >

[sqlalchemy] Multiple Database Connection

2022-03-22 Thread Mustafa Demiraslan
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

Re: [sqlalchemy] Multiple Database Connection

2022-03-22 Thread Mike Bayer
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

Re: [sqlalchemy] Multiple Database Connection

2022-03-22 Thread Mustafa Demiraslan
Yes all of these are a database not schema. Thank you for response. Mike Bayer , 22 Mar 2022 Sal, 18:27 tarihinde şunu yazdı: > 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