How To Search a Specific Record In MySQL Database Table Using Python
import mysql.connector
connection = mysql.connector.connect(
host='localhost',
user='root', password='',
port='3306',
database='test_py'
)
c = connection.cursor()
def searchData(user_id):
search_query = "SELECT * FROM `users_2` WHERE `id` = "+user_id
c.execute(search_query)
userdata = c.fetchone()
print(userdata)
searchData("7")
OUTPUT: