terminal -> pip install mysqlclient
# conda install mysqlclient
# pip install mysqlclient - 설치
import MySQLdb
import os
user='study'
passwd='study'
host='localhost'
db='studydb'
charset='utf8'
conn= MySQLdb.connect(user=user, passwd=passwd, host=host, db=db, charset=charset)
print(conn)
cursor = conn.cursor()
print(cursor)
cursor.execute('SELECT * FROM users')
for row in cursor.fetchall():
print(row)
cursor.close()
conn.close()