mysql

jinkyung·2021년 3월 12일
0

Python

목록 보기
13/19
post-custom-banner

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()


post-custom-banner

0개의 댓글