Skip to content

Instantly share code, notes, and snippets.

@samadfcibd
Created February 19, 2019 11:34
Show Gist options
  • Save samadfcibd/8b558725c441ff6b29bf077a888714e8 to your computer and use it in GitHub Desktop.
Save samadfcibd/8b558725c441ff6b29bf077a888714e8 to your computer and use it in GitHub Desktop.
# Python needs a MySQL driver to access the MySQL database.
import mysql.connector
# Start by creating a connection to the database.
mydb = mysql.connector.connect(
host="192.168.152.221",
user="ocpl",
passwd="ocpl@321",
database="bida_oss"
)
# print(mydb)
mycursor = mydb.cursor()
mycursor.execute("SELECT user_email from users")
allUser = mycursor.fetchall()
for user in allUser:
print(user)
#oneUser = mycursor.fetchone()
#print(oneUser)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment