How do I connect to a MySQL Database in Python?

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

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

25条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 08:18

    MySQLdb is the straightforward way. You get to execute SQL queries over a connection. Period.

    My preferred way, which is also pythonic, is to use the mighty SQLAlchemy instead. Here is a query related tutorial, and here is a tutorial on ORM capabilities of SQLALchemy.

提交回复
热议问题