Tinydb 简明教程
TinyDB - Introduction
What is TinyDB?
用纯 Python 编程语言编写的 TinyDB 是一个轻量级文档数据库,没有外部依赖关系。它提供了易于使用的简单 API。我们无需任何配置即可将 TinyDB 数据库用于小型项目应用。
TinyDB 模块作为 Python 程序的第三方模块提供,可用于存储、检索和修改 JSON 格式的数据。
Features of TinyDB
TinyDB 是一个干净且操作起来轻松的数据库,可操作多种格式的文档。它具有以下特性。
-
Really tiny − TinyDB 数据库本质上非常小,只有 1800 行代码和 1600 行测试。
-
Easy to use − TinyDB 易于使用,因为它具有简单且清晰的 API。
-
Document oriented − 在 TinyDB 中,我们可以存储任何文档。该文档将表示为 dict。
-
Independent − TinyDB 数据库独立于任何外部服务器和 PyPI 的外部依赖关系。
-
Compatible with Python 3.6 or latest − TinyDB 已通过测试,并与 Python 3.6 及更高版本兼容。它还可以与 PyPY3 很好地兼容。
-
Extensible − TinDB is easily extensible either by writing new storages or by modifying the behaviour of storages.
Advantages of TinyDB
TinyDB provide various benefits for students, users, and developers.
-
TinyDB is open-sourced database aand it does not require any external configirations.
-
It is quite easy-to-use, and the user can effortlessly handle documents.
-
It automatically stores documents in the database.
-
TinyDB is ideal in case of personal projects where we need to install some data.
-
It is suitable for small applications that would be blown away by large databases like SQL or an external DB server.
-
It uses a simple command line and query to operate data.
-
There is 100% test coverage i.e., no explanation needed.
Limitatations of TinyDB
TinyDB will not be the right choice for your project if you need to −
-
create indexes for tables,
-
manage relationships between tables,
-
use an HTTP server, or
-
access from multiple processors.
Comparison with Other Databases
The following table highlights how TinyDB is different from MySQL and Oracle databases −
Comparison Basis |
MySQL |
Oracle |
TinyDB |
Configurations |
Several Configurations |
Several Configurations |
Less Configurations, lightweight database |
Complicated |
Yes |
Yes |
No, easy-to-use and hustle-free |
Affordable |
No |
No |
Affordable than other databases |
Manageable |
Big database, hence difficult to manage |
Big database, hence difficult to manage |
Small and manageable |