简体   繁体   中英

Python Mysql Query Cache and use it later for join

I have 3 tables A, B and C. Among three tables 2 tables(A, B) are won't change frequently. but C changes frequently.

Now, i want to write a python programming to display all fields in 3 tables.

Here my problem is that A and B have huge data. Can i cache A join B data and use it for late to join with C?

if possible how can I ? can u explain with some python snippet ?

you can make a query cache with mysql.connector

import mysql.connector
con = mysql.connector.Connect(host='XXX', port=XXX, user='XXX',     password='XXX', database='XXX')
cur = con.cursor()
db = cur.execute("""select SELECT SQL_NO_CACHE * from abc""")
data = cur.fetchall()
print (data)

if you want to update the query result, use cur.commit()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM