Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

import sql connector (no replies)

$
0
0
Hi Folks

I amusing Windows 7 x64, Python 3.3.1, mysql connector 1.0.9

I have tried my code line by line in the Python shell which works fine, I can import the connector and connect to the database and fetch back data, BUT when I save the code as a .py the import mysql.connector does not want to work for some reason, I do have the Path variable setup and when I installed the mySQL connector it placed the relevant files in my Python install path \Lib\site-pacakges folder.

import mysql.connector #this is failing as a .py but works in the shell

cnx = mysql.connector.connect(user='root', password='mypassword', host='my_ip_address', database'name_of_database') #this works in the shell

cursor = cnx.cursor()

I have also tried my .py with just:

import mysql.connector

I get the following error:

Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1518, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Paul\Desktop\scripts\mysql.py", line 2, in <module>
import mysql.connector
File "C:\Users\Paul\Desktop\scripts\mysql.py", line 2, in <module>
import mysql.connector
ImportError: No module named 'mysql.connector'; mysql is not a package



I have tried the msi install and the independent install

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>