How do I connect to a MySQL Database in Python?

后端 未结 25 1515
眼角桃花
眼角桃花 2020-11-21 07:43

How do I connect to a MySQL database using a python program?

25条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-21 08:00

    you can connect your python code to mysql in this way.

    import MySQLdb
    db = MySQLdb.connect(host="localhost",
                     user="appuser",
                     passwd="",
                     db="onco")
    
    cursor = db.cursor()
    

提交回复
热议问题