1import mysql.connector as mysql
2
3db = mysql.connect(
4 host = "localhost",
5 user = "root",
6 passwd = "dbms",
7 database = "datacamp"
8)
9
10cursor = db.cursor()
11
12## defining the Query
13query = "SELECT * FROM users"
14
15## getting records from the table
16cursor.execute(query)
17
18## fetching all records from the 'cursor' object
19records = cursor.fetchall()
20
21## Showing the data
22for record in records:
23 print(record)
24