(deeplearning2) userdeMBP:ageAndGender user$ python
Python 2.7. |Anaconda, Inc.| (default, Dec , ::)
[GCC 4.2. Compatible Clang 4.0. (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql
Traceback (most recent call last):
File "<stdin>", line , in <module>
ImportError: No module named mysql
>>>
(deeplearning2) userdeMBP:ageAndGender user$ pip search mysql-connector | grep --color mysql-connector-python
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, . Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
mysql-connector-python (8.0.) - MySQL driver written in Python
mysql-connector-python-rf (2.2.) - MySQL driver written in Python
mysql-connector-python-dd (2.0.) - MySQL driver written in Python
(deeplearning2) userdeMBP:ageAndGender user$ pip install mysql-connector-python-rf
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, . Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting mysql-connector-python-rf

当你的环境中有多个版本时,比如有python3和python2,指定在相应环境下安装包的方法是:

pip的运行方法有多种:

1.根据-m参数按照模块运行pip,方法同运行一般的py文件。

py - -m pip install xxx
py - -m pip install xxx

2.运行相应的pip程序

pip2 install xxx
pip3 install xxx

错误:

query error!(, u"Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'testDelDuplication.gray_list_photocode.uid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by") 

原因:mysql新版本默认不支持group by语句

解决办法:

首先改@@GLOBAL.sql_mode:

SELECT @@GLOBAL.sql_mode;
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION set @@GLOBAL.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

然后改@@session.sql_mode:

SELECT @@session.sql_mode;
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION set @@session.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

python mysql使用问题的更多相关文章

  1. Python—>Mysql—>Dbvisualizer

    MySQLdb: https://pypi.python.org/pypi/MySQL-python/1.2.4 import MySQLdb 1.Download Connector/Python: ...

  2. Python Mysql 篇

    Python 操作 Mysql 模块的安装 linux: yum install MySQL-python window: http://files.cnblogs.com/files/wupeiqi ...

  3. Python MySQL ORM QuickORM hacking

    # coding: utf-8 # # Python MySQL ORM QuickORM hacking # 说明: # 以前仅仅是知道有ORM的存在,但是对ORM这个东西内部工作原理不是很清楚, ...

  4. python 之路,Day11(上) - python mysql and ORM

    python 之路,Day11 - python mysql and ORM   本节内容 数据库介绍 mysql 数据库安装使用 mysql管理 mysql 数据类型 常用mysql命令 创建数据库 ...

  5. 树莓派安装ubuntu-server,配置镜像,安装python/mysql/samba记录

    目标: 1/在raspberrypi 3B上安装ubuntu-server 2/配置好python/mysql/samba等服务,实现爬虫稳定运行我的硬件准备: 1/raspberrypi 3B 2/ ...

  6. Python/ MySQL练习题(一)

    Python/ MySQL练习题(一) 查询“生物”课程比“物理”课程成绩高的所有学生的学号 SELECT * FROM ( SELECT * FROM course LEFT JOIN score ...

  7. python/MySQL练习题(二)

    python/MySQL练习题(二) 查询各科成绩前三名的记录:(不考虑成绩并列情况) select score.sid,score.course_id,score.num,T.first_num,T ...

  8. Python/MySQL(一、基础)

    Python/MySQL(一.基础) mysql: MYSQL : 是用于管理文件的一个软件 -socket服务端 (先启动) -本地文件操作 -解析 指令[SQL语句] -客户端软件 (各种各样的客 ...

  9. Python/MySQL(二、表操作以及连接)

    Python/MySQL(二.表操作以及连接) mysql表操作: 主键:一个表只能有一个主键.主键可以由多列组成. 外键 :可以进行联合外键,操作. mysql> create table y ...

  10. Python/MySQL(三、pymysql使用)

    Python/MySQL(三.pymysql使用) 所谓pymysql就是通过pycharm导入pymysql模块进行远程连接mysql服务端进行数据管理操作. 一.在pycharm中导入pymysq ...

随机推荐

  1. 每日一题-——LeetCode(46)全排列

    题目描述: 给定一个没有重复数字的序列,返回其所有可能的全排列.输入: [1,2,3]输出:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ...

  2. P1880 [NOI1995]石子合并[环形DP]

    题目来源:洛谷 题目描述 在一个圆形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一堆的石子数,记为该次合并的得分. 试设计出1个算法,计算出将 ...

  3. Django之路——2 Django的安装

    Django的安装分为两种方式,一种是命令行安装,另外一种是pycharm安装.在这里只说一种在命令行里面安装的 1.命令行安装 这个自不必多说,直接上干货,如果遇到pip版本过低,安装失败的,请自自 ...

  4. 备份MySQL数据库并上传到阿里云OSS存储

    1. 环境配置 要将本地文件上传到阿里云oss中, 必须使用阿里云提供的工具 ossutil, 有32位,也有64位的, Linux和Windows都有.具体可以到阿里云官网下载 官网及文档: htt ...

  5. Django REST framework+Vue 打造生鲜电商项目(笔记九)

    (from:http://www.cnblogs.com/derek1184405959/p/8859309.html) 十二.支付宝沙箱环境配置 12.1.创建应用 进入蚂蚁金服开放平台(https ...

  6. SpringAOP进阶

    利用代理工厂实现增强 com.Spring.proxyfactory中的IdoSomeService package cn.spring.proxyfactory; public interface ...

  7. sql server 存储过程---游标的循环

    sqlserver中的循环遍历(普通循环和游标循环) sql 经常用到循环,下面介绍一下普通循环和游标循环 1.首先需要一个测试表数据Student

  8. myeclipse2018修改主题

  9. 关于ORA-12154: TNS:could not resolve the connect identifier specified的问题

    问题:net configuration assistant测试连接可以连接.但是PLSQL连接不了,报ORA-12154: TNS:could not resolve the connect ide ...

  10. Elasticsearch原理讲透

    小史是一个非科班的程序员,虽然学的是电子专业,但是通过自己的努力成功通过了面试,现在要开始迎接新生活了. 随着央视诗词大会的热播,小史开始对诗词感兴趣,最喜欢的就是飞花令的环节. 但是由于小史很久没有 ...