Created
May 21, 2019 14:21
-
-
Save tronghuan98hd/22ff056beb48b3efb433edbe71af4959 to your computer and use it in GitHub Desktop.
db for python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MySQLdb | |
db_server = '127.0.0.1:8080' | |
db_user = 'root' | |
db_password = '1234' | |
db_name = 'testdb' | |
db_charset = 'utf8' | |
db = MySQLdb.db.connect(db_server, db_user, db_password, db_name, charset = db_charset) | |
print('Connected') | |
cursor = db.cursor() | |
cursor.execute('SELECT * from student') | |
result = list(cursor.fetchall()) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment