Friends who are learning Python, no matter which direction they work in Python, they cannot do without databases, such as crawlers, data mining, financial quantitative analysis, etc. Let’s talk about database knowledge today.
#What is a database? A brief introduction
1. Database (Database) is a warehouse (db and dbms) that organizes, stores and manages data according to the data structure
2. Classification of databases: relational databases and Non-relational database. The Mysql we are talking about today is a typical relational database
> Characteristics of relational databases: save data in different tables, and then put these tables into the database, instead of putting all the data Put them uniformly in the database.
> Advantages: This not only increases the reading speed of Mysql, but also greatly improves the flexibility and manageability. The most commonly used standardized language for accessing and managing Mysql database is SQL structured query. statement, actually allows data to be stored persistently on the hard disk;
Python's standard database interface is Python DB-API, which provides developers with a database application programming interface.
The Python database interface supports a lot of databases. You can choose the database that suits your project:
GadFly, mSQL, MySQL, PostgreSQL
Informix, Interbase, Oracle
Sybase, Microsoft SQL, Server 2000
You can visit the Python database interface and API to view a detailed list of supported databases.
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 to provide consistent access to a variety of underlying database systems and a variety of database interface programs. access interface.
Python's DB-API implements interfaces 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 the API module.
Get the connection to the database.
Execute SQL statements and stored procedures.
Close the database connection.
The above is the detailed content of What database should I learn with Python?. For more information, please follow other related articles on the PHP Chinese website!