# 1. Open database connection
db = pymysql.connect("localhost", "user", "password", "database")
# 2. prepare a cursor object using cursor() method
cursor = db.cursor()
list = ["Lucy", "Jim", "Patrick"]
for name in list:
sql_query = "SELECT 'COUNT(*)' FROM 'database' WHERE 'Name' =%s"
result = cursor.execute(sql_query, (name,))
there is error in the last line, it says SQL syntax, i dont't know why???
import pymysql
db = pymysql.connect("localhost", "root", "", "test")
cursor = db.cursor()
list = ["English", "German"]
for name in list:
sql_query = "SELECT COUNT(*) AS cnt FROM languages WHERE name_en = %s"
result = cursor.execute(sql_query, (name,))
print(result)
--
You received this message because you are subscribed to the Google Groups "PyMySQL Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymysql-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
RegardsMiro
To unsubscribe from this group and stop receiving emails from it, send an email to pymysql-user...@googlegroups.com.