Wamp Server and Python - python

Hi i have installed WAMP server(Mysql , apache ,php) and also installed "Python" separately.Now i am trying to connect to that database using python code .
This is my python code:
#!C:\Python32\python.exe
import sys
import os
import cgi
import MySQLdb
import cgitb
import SecureDb
cgitb.enable()
print ("Content-type: text/plain\n\n");
conn= MySQLdb.connect(host = SecureDb.host ,user =SecureDb.user ,passwd=SecureDb.password ,db=SecureDb.database)
cursor=conn.cursor()
cursor.execute("select * from register where Name='Subburaj'")
result=cursor.fetchall()
cursor.close()
conn.close()
But this is showing an error:
Traceback (most recent call last):
File "C:\Users\Ponmani\Desktop\test.cgi", line 5, in <module>
import MySQLdb
File "C:\Python32\lib\site-packages\MySQLdb\__init__.py", line 17, in <module>
from release import __version__, version_info, __author__
ImportError: No module named release
If anybody came across this problem please help me to solve this.Thanks in advance.

MYSQLdb doesn't come with python. It seems that you have to install it first from here. There's an executable here, if you are using windows 32. But it's for python 2.7. If you are using python 3.2 it gets more difficult. Here's an unofficial package that should work for 3.2.
EDIT:
Release module should be a part of mysqldb, my only guess is theres is still something wrong with the installation. Maybe subforlders weren't extracted correctly.You should try to reinstall.
EDIT: you can also check if you have release.py in the mysqldb directory. if you dont it is surely installation problem.

You Need to install MySQLdb Module
easy_install MySQL-python

Related

no module name MySQLdb

I'm doing web scraping (I'm using miniconda) and I need to import the data that I got it using scrapy to a Mysql database but when I execute my program in Python 2.7 using Scrapy it says:
no module name MySQLdb
but I've installed the connection python mysql already so I don't know what is the problem...
Connector/Python 8.0.11 Windows (x86, 64-bit), MSI Installer Python
2.7
I went to shell python and I executed >>import MySQLdb to verify if it's installed correctly and it says
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import MySQLdb
ImportError: No module named MySQLdb
I've looking for other solution and I installed a lot of other versions of this connector mysql but it doesn't work
thanks in advance.

python freeopcua import error: cannot import name Client

folks, i got python 3.5.0 installed on a windows 7 machine and used pip3 to install dependencies cryptography, dateutil, lxml and pytz as mentioned on the freeopcua homepage.
thereafter I installed freeopcua using pip3 as well.
when trying to run one of the examples https://github.com/FreeOpcUa/python-opcua/blob/master/examples/client_to_kepware.py I got the error
1 import sys
2 sys.path.insert(0, "..")
3 import logging
4
5 from opcua import Client
6 from opcua import uaprotocol as ua
"Traceback (most recent call last):
File "xxx\Desktop\opcua.py", line 5, in
from opcua import Client
File "xxx\Desktop\opcua.py", line 5, in
from opcua import Client
ImportError: cannot import name 'Client'"
in my directory "xxx\Python35-32\Lib\site-packages" I do see opcua and freeopcua-0.09.3-py3.5.egg-info so it appears to be intalled correctly.
inside opcua package there is a __init__ importing
from opcua.client.client import Client from a folder client that exists on the same level as __init__. that folder has a module client.py and that module is holding class "Client". so to me everything appears fine but I am not very experienced here.
Not sure what is causing this? thanks for help!
above issue did take me quite some time and after being stuck for one evening I decided to ask. However, I eductated myself on packages that morning and appears like sys.path(0..) is the reason. Not 100% sure why it is used but it somehow changes directory. After puting file into my Python directory /Pyton35-32 it is working

Is aiopg supprted for python 3.6 now?

Today I tried to use new version of Python (3.6). I installed aiopg by pip (via PyCharm interpreter section tool).
And after I tried to import aiopg, exception was happend:
from aiopg.sa import create_engine
File "C:\Python36\lib\site-packages\aiopg\__init__.py", line 5, in <module>
from .connection import connect, Connection, TIMEOUT as DEFAULT_TIMEOUT
File "C:\Python36\lib\site-packages\aiopg\connection.py", line 4, in <module>
import fcntl
ModuleNotFoundError: No module named 'fcntl'
What is fcntl? It's linux python native module? In any case it does not work. Any solutions?
aiopg==0.11 has a regression but brand new aiopg==0.12 should work on Windows.

Unable to connect MySQL and Python

I am using python 3.5 for school project, I also already installed MySQL connector for python. I tried to import the database from MySQL but it says "MySQL module not found.
import mysql.connector
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import mysql.connector
ImportError: No module named 'mysql'
How do i solve this? any idea?
is mysql connector installed with python pip 3.5 ?
sometimes default pip is binded to default python, make sure you've installed it for correct version of python

mysql-connector-python-2.0.2-py3.3.msi Installation failed

I want to use "import MySQLdb"
So I downloaded Windows (Architecture Independent), MSI Installer Python 3.3
Address :http://dev.mysql.com/downloads/connector/python/
After the installation is complete,tell me installation failed
import MySQLdb
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'MySQLdb'
Please tell me how to do。thx.
PS:I use MySQL Server 5.5 and python33
Take a look at any example in the documentation and you will find that the module coming with oracle's mysql connector is not named MySQLdb, but simply mysql (or rather mysql.connector):
import mysql.connector
cnx = mysql.connector.connect(user='scott', password='tiger',
host='127.0.0.1',
database='employees')
cnx.close()
From:
http://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html

Categories

Resources