no server_capabilities attribute
MySQL database connector for Python programming
Brought to you by:
adustman
Didn't research this in any detail at all, just did
what I needed to get me going, and submitting this in
case someone wants to know.
Installed MySQLdb-0.9.2 and ZMySQLDA 2.0.8 on FreeBSD
with MySQL 3.23.48 (no idea of the details of these
versions, I'm not the sys admin).
ZMySQLDA product installed OK, but in trying to
instantiate a db connection, got an error that
attribute server_capabilities could not be found.
Traced the problem to line 183 of db.py, where I
cynaged the offending line to set the value manually to
0 instead of attempting to look up the value in that
attribute. Not the best solution, but it got me unstuck.
Logged In: NO
Oh yeah, I did have to use -lmysqlclient instead of
-lmysqlclient_r when I built mysqldb.
Logged In: YES
user_id=71372
What version of python? I'm guessing 2.1.3 since you are
using Zope, but I'll like to know.
Logged In: NO
Python version: No, I'm afraid it's 2.2. I had told the
owner of the server that 2.2 was not currently supported by
Zope 2.5, but for some reason he used that version anyway,
and as Zope seemed to work fine (for a while now), I didn't
complain (he's donating the space, so I want to cut him some
slack).
If's that's the problem, then I can hardly blame your product!
Logged In: YES
user_id=71372
That may be part of the problem. 2.2 is definitely
supported, but there are changes between 2.1 and 2.2 in the
handling of attributes, and I may have introduced a bug.
Logged In: YES
user_id=71372
OK, I think I can reproduce this now. It doesn't happen
using MySQLdb, only _mysql. Trying to figure out why.
Logged In: YES
user_id=35362
In fact there are no attributes at all (>=Python-2.2), just
methods in the connection object. The part for retrieving
attributes in "_mysql_ResultObject_getattr" (_mysql.c) is
disabled for "PY_VERSION_HEX >= 0x02020000"
(struct PyMemberDef is incompatible with PyMember_Get). You
can get ahead with a 2.2 version of PyMember_Get. This is
what I did to use ZMySQLDA under Python-2.2.2:
if PY_VERSION_HEX >= 0x02020000
static PyObject
MyPyMember_Get(char self, MyMemberlist(member_list), char
name)
{
MyMemberlist(l);
for (l = member_list; l->name != NULL; l++) {
if (strcmp(l->name, name) == 0)
return PyMember_GetOne((char )self, l);
}
PyErr_SetString(PyExc_AttributeError, name);
return NULL;
}
endif
Change
MyMemberlist(x) struct PyMemberDef x
to
MyMemberlist(x) PyMemberDef x
And this in the 2 _getattr methods:
return MyPyMember_Get((char *)self,
_mysql_ConnectionObject_memberlist, name);
Best regards
Bernd Rothert
Logged In: YES
user_id=71372
This has been fixed in the current CVS tree.