Newbie matter: MySQL connection

Juan Ignacio Chiapetta juanimaster at ciudad.com.ar
Mon Dec 16 18:46:56 EST 2002


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, I try to use the Connection() method, but I get this
response:

Traceback (most recent call last):
  File "<pyshell#23>", line 1, in ?
    conexion=CompatMysqldb.Connection('host', 'user','pass', 'dbname')
  File "C:\Python22\Lib\site-packages\CompatMysqldb.py", line 117, in
__init__
    self.__transactional = self.__conn.server_capabilities &
CLIENT.TRANSACTIONS
AttributeError: server_capabilities

I've tried every possible variation of username, hostname and password, in
every order, but this seems the right one, and there seems to be little
documentation for this module. The MySQL server is working fine, I can
access it via command line and PhpMyAdmin.

On the other hand, if I import _mysql and use the connection() method I have
no problem connecting:

conn=_mysql.connection('host', 'user','pass', 'dbname')

But I think I can't use cursors with that module, is that correct?

Which is the best way to connect to a MySQL database and execute queries on
that connection? Am I using the right module? I would appreciate any advice
you guys have on this subject. Thanks a lot.

Juan


---
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