为什么pd.read_sql_query真的很慢?

时间:2018-10-16 11:31:57

标签: python-3.x pandas sqlalchemy pymysql navicat

Navicat花费42秒执行查询,而python花费80秒钟甚至90多个

这是我正在使用的代码:

server = SSHTunnelForwarder(
    (bastion_host, 22),
    ssh_username=ssh_username,
    ssh_password=ssh_password,
    remote_bind_address=(sql_serverhost, 3306))

server.start()
conn = db.connect(host=localhost,
                      port=server.local_bind_port,
                      user=sql_user,
                      passwd=sql_password,
                      db=database)

mydb=create_engine('mysql+pymysql://' + sql_user + ':' + sql_password + '@' + localhost + ':' + str(server.local_bind_port) + '/' + database , echo=False)
a=dt.datetime.now()
d=pd.read_sql_query("SELECT * FROM table WHERE DATE(Date)>='2018-01-01'", conn)
b=dt.datetime.now()

c=b-a

server.stop()

0 个答案:

没有答案