• 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';
  • 相关阅读:
    分享上大学时CCTV5经常播放的一段宣传片
    嗯, 在Vista下面post一篇, 快过年的二三事
    [转自天涯]很多年以前,我是一个中锋
    关于Anthem的Button控件, 为啥仍然会PostBack?
    小白三下杭州
    搜狗, 谷歌, 紫光, 3大输入法互打结果.
    2008春节回家流水账
    早上拍的雪景.
    如果安装.net framework 3.5出错, 可以这样解决
    我那幸福的坐车偶记...
  • 原文地址:https://www.cnblogs.com/wanghui-garcia/p/10910233.html
Copyright © 2020-2023  润新知