79238462

Date: 2024-11-29 22:12:23
Score: 1.5
Natty:
Report link

I still do not know why but this method works:

import mysql.connector

cnx = mysql.connector.connect(user='scott', password='password',
                              host='127.0.0.1',
                              database='employees')
cnx.close()

But this method does not:

from mysql.connector import (connection)

cnx = connection.MySQLConnection(user='scott', password='password',
                                 host='127.0.0.1',
                                 database='employees')
cnx.close()

What puzzles me is that in the MYSQL Connector/Python developer guide it states that both work and that the first method is preferred, my luck of course.

Any ideas why, I would like to learn, fix and resolve.

Thanks,

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (1): Any ideas
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: user3146788