Python 3.4.0 with MySQL database

前端 未结 11 2518
孤城傲影
孤城傲影 2020-11-27 14:56

I have installed Python version 3.4.0 and I would like to do a project with MySQL database. I downloaded and tried installing MySQL

相关标签:
11条回答
  • 2020-11-27 15:37

    MySQLdb does not support Python 3 but it is not the only MySQL driver for Python.

    mysqlclient is essentially just a fork of MySQLdb with Python 3 support merged in (and a few other improvements).

    PyMySQL is a pure python MySQL driver, which means it is slower, but it does not require a compiled C component or MySQL libraries and header files to be installed on client machines. It has Python 3 support.

    Another option is simply to use another database system like PostgreSQL.

    0 讨论(0)
  • 2020-11-27 15:38

    for fedora and python3 use: dnf install mysql-connector-python3

    0 讨论(0)
  • 2020-11-27 15:42

    Install pip:

    apt-get install pip
    

    For acess MySQL from Python, install:

    pip3 install mysqlclient
    
    0 讨论(0)
  • 2020-11-27 15:42

    mysqlclient is a fork of MySQLdb and can serve as a drop-in replacement with Python 3.4 support. If you have trouble building it on Windows, you can download it from Christoph Gohlke's Unofficial Windows Binaries for Python Extension Packages

    0 讨论(0)
  • 2020-11-27 15:45
    sudo apt-get install python3-dev
    sudo apt-get install libmysqlclient-dev
    sudo apt-get install zlib1g-dev
    sudo pip3 install mysqlclient
    

    that worked for me!

    0 讨论(0)
提交回复
热议问题