0% found this document useful (0 votes)
39 views

MySQL - Python Connection-By S Dutta

This Python code connects to a MySQL database, retrieves login history data from a table, stores it in a list, and prints out field names and a record.

Uploaded by

bishwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

MySQL - Python Connection-By S Dutta

This Python code connects to a MySQL database, retrieves login history data from a table, stores it in a list, and prints out field names and a record.

Uploaded by

bishwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import mysql.

connector

rec = []

cnx = mysql.connector.connect(user='ideation', password='Admin@123',


host='127.0.0.1',
database='ideation')
cursor = cnx.cursor()

cursor.execute("select * from login_history")

field_names = [i[0] for i in cursor.description]

for row in cursor:


print (row)
rec.append(row)

cursor.close()
cnx.close()

print(field_names)
print (rec[5][1])

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy