Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

deleted 16 characters in body
Source Link
kai
  • 1.8k
  • 19
  • 12

for Python3.6 I found two driver: pymysql and mysqlclient. I tested the performance between them and got the result: the mysqlclient is faster.

below is my test process(need install python lib profilehooks to analyze time elapse:

raw sql: select * from FOO;

immediatly execute in mysql terminal: 46410 rows in set (0.10 sec)

pymysql (2.4s):

from profilehooks import profile
import pymysql.cursors
import pymysql
connection = pymysql.connect(host='localhost', user='root', db='tiger_quant'db='foo')
c = connection.cursor()
@profile(immediate=True)
def read_by_pymysql():
 c.execute("select * from FOO;")
 res = c.fetchall()
read_by_pymysql()

here's the pymysql profile: enter image description here


mysqlclient (0.4s)
from profilehooks import profile
import MySQLdb
connection = MySQLdb.connect(host='localhost', user='root', db='tiger_quant'db='foo')
c = connection.cursor()
@profile(immediate=True)
def read_by_mysqlclient():
 c.execute("select * from FOO;")
 res = c.fetchall()
read_by_mysqlclient()

here's the mysqlclient profile: enter image description here

So, it seems that mysqlclient is much faster than pymysql

for Python3.6 I found two driver: pymysql and mysqlclient. I tested the performance between them and got the result: the mysqlclient is faster.

below is my test process(need install python lib profilehooks to analyze time elapse:

raw sql: select * from FOO;

immediatly execute in mysql terminal: 46410 rows in set (0.10 sec)

pymysql (2.4s):

from profilehooks import profile
import pymysql.cursors
import pymysql
connection = pymysql.connect(host='localhost', user='root', db='tiger_quant')
c = connection.cursor()
@profile(immediate=True)
def read_by_pymysql():
 c.execute("select * from FOO;")
 res = c.fetchall()
read_by_pymysql()

here's the pymysql profile: enter image description here


mysqlclient (0.4s)
from profilehooks import profile
import MySQLdb
connection = MySQLdb.connect(host='localhost', user='root', db='tiger_quant')
c = connection.cursor()
@profile(immediate=True)
def read_by_mysqlclient():
 c.execute("select * from FOO;")
 res = c.fetchall()
read_by_mysqlclient()

here's the mysqlclient profile: enter image description here

So, it seems that mysqlclient is much faster than pymysql

for Python3.6 I found two driver: pymysql and mysqlclient. I tested the performance between them and got the result: the mysqlclient is faster.

below is my test process(need install python lib profilehooks to analyze time elapse:

raw sql: select * from FOO;

immediatly execute in mysql terminal: 46410 rows in set (0.10 sec)

pymysql (2.4s):

from profilehooks import profile
import pymysql.cursors
import pymysql
connection = pymysql.connect(host='localhost', user='root', db='foo')
c = connection.cursor()
@profile(immediate=True)
def read_by_pymysql():
 c.execute("select * from FOO;")
 res = c.fetchall()
read_by_pymysql()

here's the pymysql profile: enter image description here


mysqlclient (0.4s)
from profilehooks import profile
import MySQLdb
connection = MySQLdb.connect(host='localhost', user='root', db='foo')
c = connection.cursor()
@profile(immediate=True)
def read_by_mysqlclient():
 c.execute("select * from FOO;")
 res = c.fetchall()
read_by_mysqlclient()

here's the mysqlclient profile: enter image description here

So, it seems that mysqlclient is much faster than pymysql

Source Link
kai
  • 1.8k
  • 19
  • 12

for Python3.6 I found two driver: pymysql and mysqlclient. I tested the performance between them and got the result: the mysqlclient is faster.

below is my test process(need install python lib profilehooks to analyze time elapse:

raw sql: select * from FOO;

immediatly execute in mysql terminal: 46410 rows in set (0.10 sec)

pymysql (2.4s):

from profilehooks import profile
import pymysql.cursors
import pymysql
connection = pymysql.connect(host='localhost', user='root', db='tiger_quant')
c = connection.cursor()
@profile(immediate=True)
def read_by_pymysql():
 c.execute("select * from FOO;")
 res = c.fetchall()
read_by_pymysql()

here's the pymysql profile: enter image description here


mysqlclient (0.4s)
from profilehooks import profile
import MySQLdb
connection = MySQLdb.connect(host='localhost', user='root', db='tiger_quant')
c = connection.cursor()
@profile(immediate=True)
def read_by_mysqlclient():
 c.execute("select * from FOO;")
 res = c.fetchall()
read_by_mysqlclient()

here's the mysqlclient profile: enter image description here

So, it seems that mysqlclient is much faster than pymysql

default

AltStyle によって変換されたページ (->オリジナル) /