Newbie matter: MySQL connection
Gerhard Häring
gerhard.haering at gmx.de
Mon Dec 16 19:06:53 EST 2002
More information about the Python-list mailing list
Mon Dec 16 19:06:53 EST 2002
- Previous message (by thread): Newbie matter: MySQL connection
- Next message (by thread): Newbie matter: MySQL connection
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
* 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/
- Previous message (by thread): Newbie matter: MySQL connection
- Next message (by thread): Newbie matter: MySQL connection
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list