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

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.

主站蜘蛛池模板: 罗定市| 双桥区| 清河县| 沙湾县| 西城区| 铜鼓县| 措勤县| 迁西县| 铁岭市| 福清市| 通渭县| 应城市| 许昌县| 吉木萨尔县| 临朐县| 福鼎市| 广州市| 广安市| 兴国县| 大邑县| 工布江达县| 囊谦县| 革吉县| 墨竹工卡县| 秦皇岛市| 长海县| 吐鲁番市| 会东县| 垫江县| 吉安市| 灵台县| 揭西县| 龙泉市| 合水县| 罗甸县| 元谋县| 天全县| 中阳县| 韶山市| 吉木乃县| 麻城市|