在Windows中将MySQL与Python集成 [英] Integrating MySQL with Python in Windows

查看:85
本文介绍了在Windows中将MySQL与Python集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在Windows系统中很难将MySQL和Python结合使用.

I am finding it difficult to use MySQL with Python in my windows system.

我当前正在使用Python 2.6.我尝试使用提供的安装脚本来编译MySQL-python-1.2.3b1(应该适用于Python 2.6吗?)源代码.安装脚本将运行,并且不会报告任何错误,但不会生成_mysql模块.

I am currently using Python 2.6. I have tried to compile MySQL-python-1.2.3b1 (which is supposed to work for Python 2.6 ?) source code using the provided setup scripts. The setup script runs and it doesn't report any error but it doesn't generate _mysql module.

我也曾尝试为Python 2.5设置MySQL,但没有成功.使用2.5的问题是Python 2.5是使用Visual Studio 2003编译的(我使用提供的二进制文件安装了它).我在Windows系统上安装了Visual Studio 2005.因此,setuptools无法生成_mysql模块.

I have also tried setting up MySQL for Python 2.5 with out success. The problem with using 2.5 is that Python 2.5 is compiled with visual studio 2003 (I installed it using the provided binaries). I have visual studio 2005 on my windows system. Hence setuptools fails to generate _mysql module.

有帮助吗?

推荐答案

下载python-mysqldb的页面.该页面包含适用于Python 2.5、2.6和2.7的32位和64位版本的二进制文件.

Download page for python-mysqldb. The page includes binaries for 32 and 64 bit versions of for Python 2.5, 2.6 and 2.7.

还有关于摆脱弃用警告的讨论.

更新:这是一个旧答案.目前,我建议使用PyMySQL.它是纯python,因此它同样支持所有操作系统,几乎是mysqldb的直接替代品,并且还可以与python 3一起使用.最好的安装方法是使用pip.您可以从此处进行安装(更多说明

UPDATE: This is an old answer. Currently, I would recommend using PyMySQL. It's pure python, so it supports all OSes equally, it's almost a drop-in replacement for mysqldb, and it also works with python 3. The best way to install it is using pip. You can install it from here (more instructions here), and then run:

pip install pymysql

这篇关于在Windows中将MySQL与Python集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆