win10配置python与mysql环境变量,如何在Windows 10上安装和使用MySQLdb for Python 3?

My various searches seem to come up with very old posts or a mention of how to do this under cygwin. I had python 3.5 installed and then installed Anaconda3. I have python 3.5 (Cpython) installed in my user directory. I tried changing the order of how things appear in my Windows Environment Variables path, so that I could try both the Anaconda version of Python and the other version of python that I have.

Currently, I am a bit confused as to the package name that I should use. Is it python-mysqldb, or MySQLdb, or mysqldb, mysqlclient. I believe that when I had Anaconda3 in my global path (and the other version of python in my user path), I was able to install mysqlclient.

Initially, I am just trying to follow a tutorial from a training site that covers databases and uses peewee.

So, can the mysql driver for peewee be installed for python3? Or on Windows specifically?

It is easy enough to use sqlite3, one doesn't use that in production, is that right?

Can someone help me? Provide some guidance?

Also, one source of confusion is when other forms of installation of a python package are listed in the google results (many point to stack overflow), such as using easy_install, or cloning something from git. When I see instructions that are from 2010 and they reference easy_install, I had been thinking that now we can just use pip instead? Also, sometimes I see use of the conda command. Does that work the same as pip?

Thanks in advance,

Bruce

解决方案

You could use pymysql. "The goal of PyMySQL is to be a drop-in replacement for MySQLdb". Check the docs here. Install the following libraries

pip install mysqlclient pymysql

Once these libraries are installed, just add the lines in the manage.py file in your project and use the database settings for mysql.

import pymysql

pymysql.install_as_MySQLdb()

Now any files that import MySQLdb will work.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值