Using mysqldb instead of pymysql

654 views
Skip to first unread message

Luther Goh Lu Feng

unread,
Jan 12, 2011, 9:38:59 AM1/12/11
to web2py-users
I upgraded a project from 1.87.3 to 1.91.6. Pymysql is one of the new
features, replacing mysqldb.

I would like to ask if it is possible to do an override and use
mysqldb instead of pymysql. If this is not possible, would editing
gluon/dal.py to revert the patch be a possible hack?
http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835b4d0dc0e6c06a85e3f282a8&r=fc75444ca55590835b4d0dc0e6c06a85e3f282a8&format=side&path=/gluon/dal.py


Thanks in advance.

Massimo Di Pierro

unread,
Jan 12, 2011, 9:47:42 AM1/12/11
to web2py-users
that should do it. but why? pymysql is faster and more portable.

On Jan 12, 8:38 am, Luther Goh Lu Feng <elf...@yahoo.com> wrote:
> I upgraded a project from 1.87.3 to 1.91.6. Pymysql is one of the new
> features, replacing mysqldb.
>
> I would like to ask if it is possible to do an override and use
> mysqldb instead of pymysql. If this is not possible, would editing
> gluon/dal.py to revert the patch be a possible hack?http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835...
>
> Thanks in advance.

Luther Goh Lu Feng

unread,
Jan 12, 2011, 10:02:07 AM1/12/11
to web2py-users
There are some concerns that pymysql might not be ready for production
yet. Nothing specific. But mysqldb is definitely stable and tested.

On Jan 12, 10:47 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:

Luther Goh Lu Feng

unread,
Jan 12, 2011, 10:04:59 AM1/12/11
to web2py-users
Anyway these are some of the open pymysql issues http://code.google.com/p/pymysql/issues/list

Luther Goh Lu Feng

unread,
Jan 12, 2011, 10:40:03 AM1/12/11
to web2py-users
Btw, is there a link I can read about pymysql being faster and more
portable?

On Jan 12, 10:47 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:

Massimo Di Pierro

unread,
Jan 12, 2011, 10:56:25 AM1/12/11
to web2py-users
It is more portable because it is pure python (mysqldb includes c
libraries).

About faster, I remember reading something about that but this
everything I could find today:

http://code.google.com/p/pymysql/wiki/Performance

Vasile Ermicioi

unread,
Jan 12, 2011, 12:46:53 PM1/12/11
to web...@googlegroups.com
hi,

Massimo, there is a new  version of pymysql

I think pymysql has a few advantages
- being pure Python, PyMySQL is easily patched by gevent and the likes to make it cooperative


I use it with web2py and works fine

drayco

unread,
Jan 12, 2011, 10:31:55 PM1/12/11
to web2py-users
I need that some of you guys check this, in my case, Pymysql have some
issues with legacy databases (First, I think this issue is of new dal,
but I'm not sure)
However mysqldb, my application work well

this is my report:

http://groups.google.com/group/web2py/browse_thread/thread/72e91e281e0610d8/099e21f098ae8501?lnk=gst&q=new+dal#099e21f098ae8501

Luther Goh Lu Feng

unread,
Jan 14, 2011, 7:36:09 PM1/14/11
to web2py-users
To test if the issue is with pymysql, you could edit the dal file to
use mysqldb

http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835b4d0dc0e6c06a85e3f282a8&r=fc75444ca55590835b4d0dc0e6c06a85e3f282a8&format=side&path=/gluon/dal.py

On Jan 13, 11:31 am, drayco <antrod...@gmail.com> wrote:
> I need that some of you guys check this, in my case, Pymysql have some
> issues with legacy databases (First, I think this issue is of new dal,
> but I'm not sure)
> However mysqldb, my application work well
>
> this is my report:
>
> http://groups.google.com/group/web2py/browse_thread/thread/72e91e281e...

drayco

unread,
Jan 18, 2011, 7:05:03 PM1/18/11
to web2py-users
Hi, I do this revert, thank's

try:
import MySQLdb
drivers.append('MySQL')
except ImportError:
logger.debug('no MySQLdb driver')

And

self.pool_connection(lambda db=db,
user=credential_decoder(user),
password=credential_decoder(password),
host=host,
port=port,
charset=charset:
MySQLdb.Connection(db=db,

user=user,

passwd=password,

host=host,

port=port,

charset=charset,
))
In dal.py
However, the error is still appear

Traceback (most recent call last):
File "/home/drayco/web2py/gluon/restricted.py", line 188, in
restricted
exec ccode in environment
File "/home/drayco/web2py/applications/iscada/models/cfedb.py", line
16, in <module>
migrate = False)
File "/home/drayco/web2py/gluon/dal.py", line 3457, in define_table
sequence_name=sequence_name))
File "/home/drayco/web2py/gluon/dal.py", line 3741, in __init__
"primarykey must be a list of fields from table '%s " % tablename
SyntaxError: primarykey must be a list of fields from table
'med_dnpmst_4

Well I think this is a problem with compatibility.

Do you have any suggestions?

On Jan 14, 6:36 pm, Luther Goh Lu Feng <elf...@yahoo.com> wrote:
> To test if the issue is with pymysql, you could edit the dal file to
> use mysqldb
>
> http://code.google.com/p/web2py/source/diff?spec=svnfc75444ca55590835...

Massimo Di Pierro

unread,
Jan 18, 2011, 10:50:41 PM1/18/11
to web2py-users
I just included the latest pymysql in trunk. Does it make things
better?

drayco

unread,
Jan 20, 2011, 9:17:14 PM1/20/11
to web2py-users
Hi, I did my test with trunk version

this is the issue

Traceback (most recent call last):
File "/home/drayco/web2py/gluon/restricted.py", line 188, in
restricted
exec ccode in environment
File "/home/drayco/web2py/applications/iscada/models/cfedb.py", line
16, in <module>
migrate = False)
File "/home/drayco/web2py/gluon/dal.py", line 3457, in define_table
sequence_name=sequence_name))
File "/home/drayco/web2py/gluon/dal.py", line 3741, in __init__
"primarykey must be a list of fields from table '%s " % tablename
SyntaxError: primarykey must be a list of fields from table
'med_dnpmst_4

On Jan 18, 9:50 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages