hi,
i wrote the following program on python IDE. but i got "no module MySQLdb" as import error. can u give me any sugg

import MySQLdb

# Create a connection object and create a cursor
Con = MySQLdb.Connect(host="127.0.0.1", port=3306, user="rajasekhar", passwd="venkata" db="tst")
Cursor = Con.cursor()

# Make SQL string and execute it
sql = "SELECT * FROM test.Users"
Cursor.execute(sql)

# Fetch all results from the cursor into a sequence and close the connection
Results = Cursor.fetchall()
Con.close()

MySQLdb is not part of the standard python distribution; you can download it here.

MySQLdb is not part of the standard python distribution; you can download it here.

hi,
Thanks for giving your reply. but already i have downloaded that software. still, i am getting that kind of import error only. is there any process after that one.

Which tutorial are you using? I have never seen it used with
import MySQLdb
but it may be that I just don't know about that alternative way.

hi,
just i want to test the connection between python and mysql and i got this from internet itself. do, you know any other idea please send me your reply

Do you use W$ or Linux ?
Where did you install the mySqlDb module ?
Is it in your site-package directory ?
Can you see this directory in your sys.path (in Idle : "File>path Browser")

i am using mac os. yes i have mysql module in site-packages. but, still i got that kind of import error only

Check this thread I think this Thread if any more doubt please feel free t o ask

how to install MySQL-Python module on mac os. i am using mac os x 10.5
and mysql 5.0 and python 2.5. i downloaded http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz?modtime=1172959928&big_mirror=0.
still i got import module error. can you give me any sugg

Did you install that python module? or just downloaded?
ok if you did not install that module still install it. Ithink the command

Python setup.py install

will do the job. I dn't know more details about installing a pythonn module in mac os. Just do some googling it will help you to install that module. After installing that module you can run this script.

MySQLdb is just a python wrapper around MySQL. So you also have to have MySQL installed. I don't know about Mac's but you probably also have to have the MySQL daemon running. A Google for "mac mysqldb" will probably turn up thousands of hits from people who have already done this. Also, they both should be in Apple's software repository, which would install for you.

woooee you are right. But the error is import module errror. this error will occur when the module is not correctly installed. So first it should be installed properly. If there is no mysql demon running the error will be connection error.

I am using mac os. How we check whether mysql-python module is installed or not? is there any process to find out which modules we have.
And also i want to develop database application thats way i need to get a connection between html code and python program and mysql. can we extract the html component values into python to process the data.

I am using mac os. How we check whether mysql-python module is installed or not? is there any process to find out which modules we have.
And also i want to develop database application thats way i need to get a connection between html code and python program and mysql. can we extract the html component values into python to process the data.

open python shell and type in:
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb

if nothing happens and interpreter gives >>> then behold it is up and running othewise you will get traceback:
Traceback (most recent call last):
File "<string>", line 1, in <string>
ImportError: No module named MySQLdb

Hello friends.
This is Bhanu from INDIA.
I am working in a software company.
Here, we are working on Macintosh Operating Systems.
It is very new to us. And we would like to work on Python Language for our Project with back end as MySql.
We referred so many tutorials over internet. But, we are unable to access those materials.
So, we kindly need some Oral classes from your side to get through of Python and Mysql.
Please give a quick response to me.

Thanks & Regards
BhanuKiran,
Andhra Pradesh,
India.

Hai Bhanu am also frm India.

First of all you have to install python and python-mysql module for get started. Download python from www.python.org and download mysql-python from http://sourceforge.net/projects/mysql-python .
I think there is some problem with mysql-python in Macinthosh thats what we are discussing here.
If these two stuffs are ready you can start connecting to mysql database and accessing the data(MySQL also must be installed).

Check this tutorial this will help you to access mysql from python http://www.kitebird.com/articles/pydbapi.html

Thanks for the reply Nikhil.
Myself and Rajasekhar both are colleagues.
We are facing the same problem.
I already tried those steps and all. But no use.
Still getting the same error.
Are you working on mac os x?

What error do you get friend? Can you post every angle of the problem? Can you access mysql via commandline

where we can recognize all modules which we have. is there any separate module folder in our system. i mean where all these modules like MySQLdb and web modules will store after installation. can u give me any sugg

In Linux typing >>help() then >>modules will list the available modules

In windows we can check it by looking in the lib folder placed inside the python folder.

I don't know exactly what to do in Mac OS X. So just try any of the above methods.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.