it-source

mariadb와 python2.7을 연결하는 방법이 있습니까?

criticalcode 2023. 1. 23. 10:10
반응형

mariadb와 python2.7을 연결하는 방법이 있습니까?

mac OSX에서는 python2.7과 mariadb를 사용하려고 합니다.사용하고 있다pip install mysql-python또는pip install mysqlclient커넥터로 사용합니다.하지만 시스템은 항상 나에게 많은 오류를 준다.이 문제를 해결할 다른 방법이 있나요?

ERROR: Command errored out with exit status 1:
   command: /Users/eskimi/Development/ErpNext/frappe-bench/env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-install-gccSRs/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-install-gccSRs/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-wheel-MTABvV --python-tag cp27
       cwd: /private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-install-gccSRs/mysql-python/
  Complete output (41 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.14-intel-2.7
  copying _mysql_exceptions.py -> build/lib.macosx-10.14-intel-2.7
  creating build/lib.macosx-10.14-intel-2.7/MySQLdb
  copying MySQLdb/__init__.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
  copying MySQLdb/converters.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
  copying MySQLdb/connections.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
  copying MySQLdb/cursors.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
  copying MySQLdb/release.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
  copying MySQLdb/times.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
  creating build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
  copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
  running build_ext
  building '_mysql' extension
  creating build/temp.macosx-10.14-intel-2.7
  cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mariadb/10.4.6_1/include/mysql -I/usr/local/Cellar/mariadb/10.4.6_1/include/mysql/.. -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.14-intel-2.7/_mysql.o
  In file included from _mysql.c:44:
  /usr/local/Cellar/mariadb/10.4.6_1/include/mysql/my_config.h:3:2: warning: This file should not be included by clients, include only <mysql.h> [-W#warnings]
  #warning This file should not be included by clients, include only <mysql.h>
   ^
  In file included from _mysql.c:46:
  /usr/local/Cellar/mariadb/10.4.6_1/include/mysql/mysql.h:441:3: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    MYSQL_CLIENT_PLUGIN_HEADER
    ^
  /usr/local/Cellar/mariadb/10.4.6_1/include/mysql/mysql.h:437:16: note: expanded from macro 'MYSQL_CLIENT_PLUGIN_HEADER'
    int (*deinit)();                                      \
                 ^
  _mysql.c:2005:42: error: no member named 'reconnect' in 'struct st_mysql'
          if ( reconnect != -1 ) self->connection.reconnect = reconnect;
                                 ~~~~~~~~~~~~~~~~ ^
  2 warnings and 1 error generated.
  error: command 'cc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for mysql-python
    ERROR: Command errored out with exit status 1:
     command: /Users/eskimi/Development/ErpNext/frappe-bench/env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-install-gccSRs/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-install-gccSRs/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-record-PZ6DCs/install-record.txt --single-version-externally-managed --compile --install-headers /Users/eskimi/Development/ErpNext/frappe-bench/env/include/site/python2.7/mysql-python
         cwd: /private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-install-gccSRs/mysql-python/
    Complete output (41 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-intel-2.7
    copying _mysql_exceptions.py -> build/lib.macosx-10.14-intel-2.7
    creating build/lib.macosx-10.14-intel-2.7/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb
    creating build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14-intel-2.7/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.14-intel-2.7
    cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mariadb/10.4.6_1/include/mysql -I/usr/local/Cellar/mariadb/10.4.6_1/include/mysql/.. -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.14-intel-2.7/_mysql.o
    In file included from _mysql.c:44:
    /usr/local/Cellar/mariadb/10.4.6_1/include/mysql/my_config.h:3:2: warning: This file should not be included by clients, include only <mysql.h> [-W#warnings]
    #warning This file should not be included by clients, include only <mysql.h>
     ^
    In file included from _mysql.c:46:
    /usr/local/Cellar/mariadb/10.4.6_1/include/mysql/mysql.h:441:3: warning: this function declaration is not a prototype [-Wstrict-prototypes]
      MYSQL_CLIENT_PLUGIN_HEADER
      ^
    /usr/local/Cellar/mariadb/10.4.6_1/include/mysql/mysql.h:437:16: note: expanded from macro 'MYSQL_CLIENT_PLUGIN_HEADER'
      int (*deinit)();                                      \
                   ^
    _mysql.c:2005:42: error: no member named 'reconnect' in 'struct st_mysql'
            if ( reconnect != -1 ) self->connection.reconnect = reconnect;
                                   ~~~~~~~~~~~~~~~~ ^
    2 warnings and 1 error generated.
    error: command 'cc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/eskimi/Development/ErpNext/frappe-bench/env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-install-gccSRs/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-install-gccSRs/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/1r/0z4_dp3j0237vqx1jvc0sn3c0000gp/T/pip-record-PZ6DCs/install-record.txt --single-version-externally-managed --compile --install-headers /Users/eskimi/Development/ErpNext/frappe-bench/env/include/site/python2.7/mysql-python Check the logs for full command output.
Traceback (most recent call last):

API 기능을 사용하는 대신 내부/문서화되어 있지 않은 구성원에 접근해서는 안 되는 좋은 예입니다.

MariaDB의 클라이언트 라이브러리는 MYSQL 구조에 재연결 옵션이 없습니다. MySQL 및 MariaDB 설명서에 따르면 재연결 옵션은 다음을 통해 설정해야 합니다.mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);

그러나 이 문제는 MySQLDB에서 이미 해결되었으므로 최신 소스를 다운로드하여 모듈을 로컬로 빌드해야 합니다(Python 2.7 모듈은 더 이상 업데이트되지 않을 것으로 가정함).

언급URL : https://stackoverflow.com/questions/58620880/is-there-a-way-to-connect-mariadb-with-python2-7

반응형