Read MYSQL Table data from Python Code

First we need to import mysql module

Create connection to MySql Database and fetch the records.


Complete code given below-

 import mysql.connector

from mysql import connector


conn = mysql.connector.connect(host='127.0.0.1',database='firstschema',user='root',password='2511')

cursor=conn.cursor()

cursor.execute('SELECT * from firstschema.check1')

values=cursor.fetchall()

print(values)

Comments

Popular posts from this blog

[Solved]SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Read the excel and insert data into My SQL using Python