The Python database interface supports a lot of databases, you can choose the database that suits your project:
GadFlymSQL MySQL PostgreSQL Microsoft SQL Server 2000 InformixInterbase Oracle Sybase
You need to download different DB API modules for different databases. For example, if you need to access Oracle database and Mysql data, you need to download Oracle and MySQL database modules.
DB-API is a specification. It defines a series of necessary objects and database access methods in order to provide a consistent access interface for various underlying database systems and various database interface programs.
Python's DB-API implements an interface for most databases. After using it to connect to each database, you can operate each database in the same way.
Python DB-API usage process:
Introduce API module. Get the connection to the database. Execute SQL statements and stored procedures. Close the database connection.
MySQLdb
MySQLdb is an interface for Python to link to Mysql database. It implements the Python database API specification V2.0 and is based on the MySQL C API.
installation
Use pip to install directly. Before that, you need to install some system dependencies.
CentOSyum install gcc python-devel mysql-devel zlib-devel openssl-devel
Ubuntusudo apt-get install libmysqlclient-dev libmysqld-dev python-dev python-setuptools
After installing the dependencies, use pip to install directly. The name of the MySQLdb module is called MySQL-python on pip.
Knowledge point expansion:
Use python to connect to mysql database
Six commonly used connection parameters
So far, this article on the ways to connect python to mysql is introduced. For more information about how to connect python to mysql, please search for previous articles on ZaLou.Cn or continue to browse related articles below. Hope you will support ZaLou.Cn more in the future. !
Recommended Posts