Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tronghuan98hd/22ff056beb48b3efb433edbe71af4959 to your computer and use it in GitHub Desktop.
Save tronghuan98hd/22ff056beb48b3efb433edbe71af4959 to your computer and use it in GitHub Desktop.
db for python
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