Three articles to help you figure out how to learn mysql database and install SQL database

Tomorin
Release: 2018-08-16 13:53:10
Original
1666 people have browsed it

MySQL database is an interface for Python to connect to the Mysql database. It implements the Python database API specification V2.0 and is based on the MySQL C API. In other words, it uses the most concise Python languageTo control the MYSQL database:

So, what is the MySQL database?

MySQLdb is an interface for Python to connect to the Mysql database. It implements the Python database API specification V2.0 and is based on the MySQL C API.

How to install MySQL database?

In order to write MySQL scripts using DB-API, you must ensure that MySQL is installed. Copy the following code and execute it:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import MySQLdb
Copy after login

If the output after execution is as follows, it means you have not installed the MySQLdb module:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    import MySQLdb
ImportError: No module named MySQLdb
Copy after login

To install MySQLdb, please visit http://sourceforge. net/projects/mysql-python , (Linux platform can visit: https://pypi.python.org/pypi/MySQL-python) From here, you can choose the installation package suitable for your platform, which is divided into precompiled binary files and Source code installation package.

If you choose the binary file release version, the installation process will be completed with basic installation prompts. If you are installing from source code, you need to switch to the top-level directory of the MySQLdb distribution and type the following command:

$ gunzip MySQL-python-1.2.2.tar.gz
$ tar -xvf MySQL-python-1.2.2.tar
$ cd MySQL-python-1.2.2
$ python setup.py build
$ python setup.py install
Copy after login

Note: Please make sure you have root permissions to install the above modules.

The above is the detailed content of Three articles to help you figure out how to learn mysql database and install SQL database. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template