python: fetch mysql db data row wise

import mysql.connector
from mysql.connector import Error, cursor


try:
    con=mysql.connector.connect(host='localhost',database='qedge',user='root',password='****')
    if con.is_connected():
        squery='Select * from qedge.dms';
        cursor=con.cursor()
        cursor.execute(squery)
       
        rows=cursor.fetchall()
        for row in rows:
            print(row)       
except Error as e:
    print(e)
finally:
    cursor.close
    con.close()
    

Comments

Popular posts from this blog

Arrays

What is the difference between eval, execute and executeglobal.

Sample Test Strategy for a MicroService Project with APIs only