将 Canopy 连接到 mysql

connecting Canopy to mysql

我是 Python 的新手,使用 Enthought Canopy Express 进行学习。作为其中的一部分,我正在寻找将 Canopy 连接到 mysql 的选项。我没有找到任何材料。如果您知道我可以在 Canopy Express 中使用 mysql 的任何方法,请分享。

我正在使用 Mac OS X 版本 10.9

树冠的路径是: /Users/mz/Library/Enthought/Canopy_64bit/User/lib/python2.7/站点包

Mysql是5.6版本,路径如下: mysql 是 /usr/local/mysql/bin/mysql

您可以使用 Canopy 包管理器安装 pymysql

安装完成后,根据Python PEP249 DB API访问pymysql(创建连接,获取游标等):

In [1]: import pymysql

In [2]: connection = pymysql.connect?
Signature: pymysql.connect(*args, **kwargs)
Docstring:
        Establish a connection to the MySQL database. Accepts several
        arguments:

        host: Host where the database server is located
        user: Username to log in as
        password: Password to use.
        database: Database to use, None to not use a particular one.
        port: MySQL port to use, default is usually OK.
...