jkklee / pymysql-pool

A simple but robust connection pool (with multiplexing) base on PyMySQL, mainly used for multi threads mode, which also compatible with single thread mode.
GNU General Public License v3.0
177 stars 49 forks source link

Last version 0.4.6 doesn't honor cursorclass #21

Closed fncfnc closed 11 months ago

fncfnc commented 1 year ago

My cursorclass setting is pymysql.cursors.DictCursor but I receive a tuple

jkklee commented 1 year ago

that’s not good, but I make a test and I think it's right, can you show me your code? @fncfnc

jkklee commented 1 year ago

@fncfnc, my test code:

import pymysql
import pymysqlpool
ps10=pymysqlpool.ConnectionPool(host="x.x.x.x",database="xxx",user="xxx",password="xxxxxx")
cs10=ps10.get_connection()

# Scenario 1 to get a dict cursor
cus10=cs10.cursor(pymysql.cursors.DictCursor)           
cus10
<pymysqlpool.DictCursor object at 0x10c31d790>      # DictCursor object 
cus10.execute('select 1+1')
1
cus10.fetchall()
[{'1+1': 2}]                              # dict result

##############################

# Scenario 2 to get a dict cursor
ps11=pymysqlpool.ConnectionPool(host="x.x.x.x",database="xxx",user="cld_w",password="xxx",cursorclass=pymysql.cursors.DictCursor)                    
cs11=ps11.get_connection()

cus11=cs11.cursor()
cus11
<pymysqlpool.DictCursor object at 0x10bac5cd0>     # DictCursor object 
cus11.execute('select 1+1')
1
cus11.fetchall()
[{'1+1': 2}]                                # dict result
fncfnc commented 1 year ago

Ok also for me, now the error disappeared. I don't know what happended, but for sure error happened few second after 0.4.6 release, because a was continuously publishing my AWS Lambda and Lambda exited expecting dict but got tuple. Could be related for my python environment be Linux/Aarch64?