domingo, 6 de setembro de 2020

Python SQLAlchemy

sudo apt-get install python3-dev

 to

pip install mysqlclient

 

 sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

 

Edite o arquivo my.cnf

Insira a linha abaixo e escolha a quantidade de conexões que deseja

Reinicie o Mysql

1
# service mysqld restart

 

app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
app.config["SQLALCHEMY_BINDS"] = SQLALCHEMY_BINDS
app.config["SQLALCHEMY_POOL_RECYCLE"] = 280
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

 

show global variables like '%connections%'

You can find out how many connections are in use at any given moment like this:

show status like '%connected%'

You can find out what each connection is doing like this:

show full processlist
 
 

Read max_connections document to solve your problem

If clients encounter Too many connections errors when attempting to connect to the mysqld server, all available connections are in use by other clients.

The permitted number of connections is controlled by the max_connections system variable. The default value is 151 to improve performance when MySQL is used with the Apache Web server. To support more connections, set max_connections to a larger value.

First: Check your current database max_connection variable

SHOW VARIABLES LIKE 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151   |
+-----------------+-------+

Then Try to increase the max_connection parameter either with running command like:

 SET GLOBAL max_connections = 300;

Or set this parameter in my.cnf that located at /etc/my.cnf

vi /etc/my.cnf
max_connections = 300

 

Nenhum comentário:

Postar um comentário