Reputation: 21
I am using Python 3.6 and mysql-connector 2.1.6 on macOS High Sierra. Following the instructions in the example on this documentation page 'https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlconnectionpool-constructor.html', when I attempt to create a connection pool as follows:
cnxpool = mysql.connector.pooling.MySQLConnectionPool(pool_name = "mypool",pool_size = 3,**dbconfig)
I get the following error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2869, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-b07112a83246>", line 1, in <module>
cnxpool = mysql.connector.pooling.MySQLConnectionPool(pool_name = "mypool",pool_size = 3,\**dbconfig)
AttributeError: module 'mysql.connector' has no attribute 'pooling'**
I have provided a valid **dbconfig argument.
May someone please help explain why it's not working?
Upvotes: 1
Views: 1729
Reputation: 4379
You have to import the pooling by using this line of code.
import mysql.connector.pooling
Upvotes: 4