← 返回 openai 的题目列表In-Memory Key-Value Database CRUD Implementation
类型:online_judge
openai
Implement an in-memory database that supports basic CRUD operations.
The database should support the following features:
Insert operation: Insert a record into the database, which contains a key and a corresponding value.
Query operation: Query the value from the database based on the key. If the key does not exist, return null.
Update operation: Update the value of a record in the database based on the key. If the key does not exist, throw an exception.
Delete operation: Delete a record from the database based on the key.
Please implement the above features using Python and design appropriate test cases to verify the correctness of the functionality.
Input: Specific operations and data Output: Database state after each operation
Example
Input
insert key1 value1
query key1
update key1 value2
query key1
delete key1
query key1