Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- import time
- class MyDataBase():
- def __init__(self):
- self.mydb = mysql.connector.connect(
- host="localhost",
- user="root",
- passwd="",
- database="python",
- autocommit=True)
- self.mycursor = self.mydb.cursor()
- self.sql = ""
- self.val = ""
- def GetData(self):
- try:
- self.sql = "SELECT id, lastname, firstname, email FROM python"
- self.mycursor.execute(self.sql)
- myresult = self.mycursor.fetchall()
- for row in myresult:
- print(row)
- except:
- print("Error")
- email = MyDataBase()
- print("Querying Database...")
- email.GetData()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement