Given a simple table
with 10 records, if I run
the db connection gets closed (SHOW PROCESSLIST in MySql does not show any connections in sleep state).
If I just append
at the end of that code, and run it all, the connection stays in the sleep state. Every time I run the code, a new connection is opened and remains open until the timeout (default 8h on MySql). After a while "mysql: Failed to connect (Too many connections)" happens.