esnme / ultramysql

A fast MySQL driver written in pure C/C++ for Python. Compatible with gevent through monkey patching.
http://www.esn.me
Other
547 stars 95 forks source link

connecting to AWS RDS instance fails #7

Closed fevral13 closed 12 years ago

fevral13 commented 12 years ago

When I try to connect with ultramysql to Amazon's db instance, I get weird exception:

In [1]: import umysql

In [2]: conn = umysql.Connection()

In [3]: conn.connect('xxxxx.us-east-1.rds.amazonaws.com', 3306, 'xxxxx', 'xxxxx', 'xxxxx')
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
/home/fevral13/<ipython-input-3-213a95b4356f> in <module>()
----> 1 conn.connect('xxxxx.us-east-1.rds.amazonaws.com', 3306, 'xxxxx', 'xxxxx', 'xxxxx')

SystemError: error return without exception set

In [4]: conn.is_connected()
Out[4]: True

In [5]: conn.query('select 1')
---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)
/home/fevral13/<ipython-input-5-4ec56317c561> in <module>()
----> 1 conn.query('select 1')

Error: (0, 'Connection reset by peer when receiving')

But when I use pymysql, for example, everything works:

In [6]: import pymysql

In [7]: c = pymysql.Connect(host='xxxxx.us-east-1.rds.amazonaws.com', port=3306, user='xxxxx', passwd='xxxxx', db='xxxxx')

In [8]: c.query('select 1')
Out[8]: 1

So the db is up and connectable

fevral13 commented 12 years ago

And no problem connecting to local mysql server:

In [1]: import umysql

In [2]: conn = umysql.Connection()

In [3]: conn.connect('localhost', 3306, 'root', '', '')

In [4]: conn.query('select 1')
Out[4]: <umysql.ResultSet at 0x2c66cc0>
jskorpan commented 12 years ago

Are you using gevent?

Den 12 februari 2012 11:27 skrev Serj Zavadsky < reply@reply.github.com

:

When I try to connect with ultramysql to Amazon's db instance, I get weird exception:

In [1]: import umysql

In [2]: conn = umysql.Connection()

In [3]: conn.connect('xxxxx.us-east-1.rds.amazonaws.com', 3306, 'xxxxx', 'xxxxx', 'xxxxx')


SystemError Traceback (most recent call last) /home/fevral13/ in () ----> 1 conn.connect('xxxxx.us-east-1.rds.amazonaws.com', 3306, 'xxxxx', 'xxxxx', 'xxxxx')

SystemError: error return without exception set

In [4]: conn.is_connected() Out[4]: True

In [5]: conn.query('select 1')


Error Traceback (most recent call last) /home/fevral13/ in () ----> 1 conn.query('select 1')

Error: (0, 'Connection reset by peer when receiving')

But when I use pymysql, for example, everything works:

In [6]: import pymysql

In [7]: c = pymysql.Connect(host='xxxxx.us-east-1.rds.amazonaws.com', port=3306, user='xxxxx', passwd='xxxxx', db='xxxxx')

In [8]: c.query('select 1') Out[8]: 1

So the db is up and connectable


Reply to this email directly or view it on GitHub: https://github.com/esnme/ultramysql/issues/7

Jonas Trnstrm Product Manager e-mail: jonas.tarnstrom@esn.me skype: full name "Jonas Trnstrm" phone: +46 (0)734 231 552

ESN Social Software AB www.esn.me

fevral13 commented 12 years ago

Yes, I'm using ultramysql with gevent. Creating connection pool with gevent.queue.Queue:

DB_CONNECTION_POOL = 10
pool = Queue()
for i in xrange(DB_CONNECTION_POOL):
    c = Connection()
    c.connect(DATABASE_HOST, DATABASE_PORT, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME)
    pool.put(c)

and using it:

    c = pool.get()
    result = c.query('query')
    pool.put(c)

everything works with local mysql server

jskorpan commented 12 years ago

Then there's something different with Amazon's db instances. If you can spare a DB account for me I could probably have a look at it.

//JT

Den 13 februari 2012 12:20 skrev Serj Zavadsky < reply@reply.github.com

:

Yes, I'm using ultramysql with gevent. Creating connection pool with gevent.queue.Queue:

DB_CONNECTION_POOL = 10 pool = Queue() for i in xrange(DB_CONNECTION_POOL): c = Connection() c.connect(DATABASE_HOST, DATABASE_PORT, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME) pool.put(c)

and using it:

   c = pool.get()
   result = c.query('query')
   pool.put(c)

everything works with local mysql server


Reply to this email directly or view it on GitHub: https://github.com/esnme/ultramysql/issues/7#issuecomment-3937953

Jonas Trnstrm Product Manager e-mail: jonas.tarnstrom@esn.me skype: full name "Jonas Trnstrm" phone: +46 (0)734 231 552

ESN Social Software AB www.esn.me

fevral13 commented 12 years ago

sent connection details to jonas.tarnstrom@esn.me

jskorpan commented 12 years ago

Hi, Thanks for the assistance I can connect now with the latest commit.

fevral13 commented 12 years ago

Hi, Jonas,

thank you very much!