Python MySQL Search

How To Search a Specific Record In MySQL Database Table Using Python

Python MySQL Search


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:

Python MySQL Search





Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer