top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

MySQL support for Python3?

0 votes
513 views

I'm starting a new project from scratch so I think its finally a time to switch to the latest and greatest Python 3.4.

But I'm puzzled with MySQL support for Python 3. So far the only stable library I've found it pymysql.

All others are either abandoned work-in-progress projects or do not support Python 3:

  • mysqldb - Python 2.x only
  • mysql-ctypes - Python 2.x only
  • amysql - Python 2.x only
  • ultramysql - Python 2.x only
  • MySQL Connector/Python - new guy in block. Does anyone use it?
  • WebScaleSQL + MySQLdb1 - still in development, state unknown?

So what library do you use for MySQL access in Python 3? I'm specifically interested in async support (like in psycopg2 for PostgreSQL) since I'm planning to use Tornado.

posted Jun 24, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

PyMySQL -- pure Python MySQL connector. Supports Python 3.3.
mysqlclient -- Fork of MySQLdb. Supports Python 3.3.

answer Jun 24, 2014 by Navneet
Similar Questions
0 votes

I need a command that will make threads created by "multiprocessing.Process()" wait for each other to complete. For instance, I want to do something like this:

job1 = multiprocessing.Process(CMD1())
job2 = multiprocessing.Process(CMD2())

jobs1.start(); jobs2.start()

PY_FUNC()

The command "PY_FUNC()" depends on the end result of the actions of CMD1() and CMD2(). I need some kind of wait command for the two threads that will not let the script continue until job1 and job2 are complete. Is this possible in Python3?

+1 vote

I seem to stumble upon a situation where "!=" operator misbehaves in python2.x. Not sure if it's my misunderstanding or a bug in python implementation. Here's a demo code to reproduce the behavior -

From __future__ import unicode_literals, print_function

class DemoClass(object):
   def __init__(self, val):
   self.val = val

   def __eq__(self, other):
   return self.val == other.val

  x = DemoClass('a')
  y = DemoClass('a')

  print("x == y: {0}".format(x == y))
  print("x != y: {0}".format(x != y))
  print("not x == y: {0}".format(not x == y))

In python3, the output is as expected:

x == y: True
x != y: False
not x == y: False

In python2.7.3, the output is:

x == y: True
x != y: True
not x == y: False

which is not correct!!

+2 votes

What's the problem with Python 3.x? It was first released in 2008, but web hosting companies still seem to offer Python 2.x rather.

For example, Google App Engine only offers Python 2.7. What's wrong?...

0 votes

I am trying to create one SSH tunnel, so that i can connect from a python script running on my pc, to a remote MySQL database running on my Host and id like to stick with Python 3.3 .

I contacted my host and he informed me that this is the only way.

I tried pycrypto + paramiko but from what i have noticed, paramiko is not Python 3.3 ready. Any thoughts?

+1 vote

Is there a way to make python script that connects to mySQL DB ask for a password on the:

conn = mdb.connect(host, user)
...