官术网_书友最值得收藏!

Accessing databases

Text files are good when they are small and when they don't need to be changed often. Actually, the only way that a text file can be changed is if you append something to the end of it or rewrite it completely. If you want to change the information in a large dataset quickly, the only way to do so is to use a database manager. In this section, we are going to learn how to manipulate a SQLite database with a simple example.

But first, let's look at three popular, broad categories of database managers:

  • Single-user databases: These store all of the databases in a single file, which must be accessible by the application code. The database code is linked into the application (it may be a static-link library or a dynamic-link library). Only one user at a time is allowed to access it, and all users have administrative privileges. To move the database anywhere, you simply move the file. The most popular choices in this category are SQLite and Microsoft Access.
  • DBMS: This is a process that has to be started as a service. Multiple clients can connect to it at the same time, and they can also apply changes at the same time without any data corruption. It requires more storage space, more memory, and much more start up time (for the server). There are several popular choices in this category, such as Oracle, Microsoft SQL Server, IBM DB2, MySQL, and PostgreSQL.
  • Key-value stores: This is a process that has to be started as a service. Multiple clients can connect to it at the same time and apply changes at the same time. It is essentially a large memory hash map that can be queried by other processes and that can optionally store its data in a file and reload it when it is restarted. This category is less popular than the other two, but it is gaining ground as the backend of high-performance websites. One of the most popular choices is Redis.

In the following sections, we are going to show you how to access SQLite single-user databases (in the sqlite_example project), PostgreSQL DBMSes (in the postgreSQL_example project), and Redis key-value stores (in the redis_example project). Then, in the transformer project, all three kinds of databases will be used together.

主站蜘蛛池模板: 台前县| 兰州市| 改则县| 兰溪市| 沂水县| 旺苍县| 钟山县| 美姑县| 田阳县| 连平县| 珲春市| 澳门| 息烽县| 遂宁市| 乌海市| 恩平市| 文化| 赣州市| 横山县| 沂源县| 德令哈市| 什邡市| 抚宁县| 电白县| 兰西县| 孝感市| 商丘市| 偏关县| 青岛市| 东源县| 九寨沟县| 江孜县| 安新县| 长海县| 定安县| 阿坝| 清水河县| 东乌珠穆沁旗| 泉州市| 敦化市| 平泉县|