When you have a table called X in the Workbench (in which you have columns called value1, value2) and you define a list called A=[1,2,3]
in Python, what should I do with this Python mysql code? For example, the Value column of X has the same value as A[2]
"Select X.value2 where X.value1=A[2]"
I want to write a code with this meaning.
import pymysql
a = [1,2,3]
db = pymysql.connect(host='', port=3306, user='',passwd='', db='', charset='utf8')
cur = db.cursor()
sql = "select value2 from Table where value1=%s"
cur.execute(sql,(a[2]))
r = cursor.fatchall()
for i in r:
print(i)
There are many use cases of pymysql on Google.
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
612 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.