0

I am using Peewee ORM to update and modify database table from my python project. I have set max connection limit to 15 using:

set global max_connections = 15

to get total connection I run the command,

> select count(*) from  information_schema.processlist;

> 12

now that connection limit is 15 and even if I run a my code to do some work on db by opening a connection the number of connection goes up by 2

> select count(*) from  information_schema.processlist;

> 14

now even if am done doing the task, I close python terminal I still see total number of connection from process list count to be 14, it seems like old connections get reused or what, if I run the same command to update db table, from different terminal I add 2 more connection but it gives error saying too many connections. but the first terminal I had opened still work.

I can post peewee code if required.

4
  • I'm unclear about the exact scenario here. You open a terminal and keep it open, and then you open some other terminal and it can't connect because of too many connections, but the first terminal which was already open keeps working…? Well, yes, that is to be expected. Commented Sep 27, 2018 at 9:11
  • but connect_timeout is set to 10 seconds then why even if python terminal is open does mariadb maintains the connection ? Commented Sep 27, 2018 at 9:20
  • what do you think connect_timeout does? Commented Sep 28, 2018 at 22:22
  • And if you repeat, will it again go up by 2 and down by 1? Or 1 and 1? Commented Oct 9, 2018 at 18:30

1 Answer 1

0

If you are using the regular MySQLDatabase class, then calling .close() on the connection will close it.

On the other hand if you are using PooledMySQLDatabase, .close() will recycle the connection to the pool of available connections. You can manage the connections in the pool using the following APIs: http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#PooledDatabase

Sign up to request clarification or add additional context in comments.

1 Comment

If I am not wrong if we use Proxy class to initialize database later it needs to be closed manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.