zoukankan      html  css  js  c++  java
  • python mysql使用问题

    (deeplearning2) userdeMBP:ageAndGender user$ python 
    Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 13:10:39) 
    [GCC 4.2.1 Compatible Clang 4.0.1 (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 1, 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, 2020. 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.16)                           - MySQL driver written in Python
    mysql-connector-python-rf (2.2.2)                         - MySQL driver written in Python
    mysql-connector-python-dd (2.0.2)                         - 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, 2020. 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 -2 -m pip install xxx
    py -3 -m pip install xxx

    2.运行相应的pip程序

    pip2 install xxx
    pip3 install xxx

    错误:

    query error!(1055, 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';
  • 相关阅读:
    Solution -「ARC 101D」「AT4353」Robots and Exits
    Solution -「多校联训」轮回
    Solution -「多校联训」种蘑菇
    Solution -「多校联训」染色
    luoguP4389 完全背包计数
    Js 之notification浏览器桌面通知
    Linux 之shell脚本调用另一个shell脚本
    Linux 之开机自启动脚本
    Js 之简单ajax封装
    PHP 之phpsocket.io客户端主动推送给服务器
  • 原文地址:https://www.cnblogs.com/wanghui-garcia/p/10910233.html
Copyright © 2011-2022 走看看