1

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?

Daniel Roseman
602k68 gold badges911 silver badges924 bronze badges
asked Apr 15, 2018 at 11:24
3
  • 2
    Did you import mysql.connector.pooling, or just part of that? Commented Apr 15, 2018 at 11:34
  • I imported import mysql.connector Commented Apr 15, 2018 at 11:38
  • After importing import mysql.connector.pooling it works. Thanks @Alex Hall Commented Apr 15, 2018 at 11:40

1 Answer 1

4

You have to import the pooling by using this line of code.
import mysql.connector.pooling

answered Jun 14, 2020 at 23:40
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.