Newbie matter: MySQL connection

Juan Ignacio Chiapetta juanimaster at ciudad.com.ar
Tue Dec 17 07:17:57 EST 2002


Thank you all... I don't know why I didn't use MySQLdb in the first place!!!
Thanks again

Juan

----- Original Message -----
From: "Gerhard Häring" <gerhard.haering at gmx.de>
To: <python-list at python.org>
Sent: Monday, December 16, 2002 9:06 PM
Subject: Re: Newbie matter: MySQL connection


> * Juan Ignacio Chiapetta <juanimaster at ciudad.com.ar> [2002-12-16
20:46 -0300]:
> > Hi everyone, I'm just starting with Python and I want to connect to a
MySQL
> > database. I'm using mysql-python-0.9.2 on Windows XP, with Python 2.2
and
> > MySQL 3.23.38
> > I can't get Python to connect to my database, here's the problem. If I
> > import CompatMysqldb,
>
> Don't. See this comment in CompatMysqldb.py:
>
>     [...]It is intended for backwards compatibility purposes only.[...]
>
> > I try to use the Connection() method, but I get this
> > response:
>
> :-/
>
>     $ sudo find /|grep CompatMySQLdb.py|xargs rm -f
>
> *eg*
>
> Forget about this module. The one to use is MySQLdb. And you use it like
> this:
>
> #v+
> import smtplib
> import MySQLdb
>
> con = MySQLdb.connect(host="myhost", user="me", passwd="sicrit",
db="blackmailing_profits")
>
> cursor = con.cursor()
> cursor.execute("select boss_email, victim_email from profits where amount
> 1000")
> for row in cursor.fetchall():
>     # [do evil stuff]
>
> For documentation, download the MySQLdb source distribution and look
> into doc/MySQLdb.html.
>
> HTH,
>
> Gerhard
> --
> Favourite database:             http://www.postgresql.org/
> Favourite programming language: http://www.python.org/
> Combine the two:                http://pypgsql.sf.net/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002





More information about the Python-list mailing list