Skip to content

nopde/python-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

python-db

This is a Python class that manages a simple key-value database. The class provides methods to create, update, delete, and retrieve key-value pairs.

Usage

  • Import the Database class:
from database import Database
  • Create an instance of the Database class with a name for the database:
db = Database("my_database")
  • You can also provide an initial dictionary of key-value pairs:
initial_data = { "name": "John Doe", "age": 30 }
db = Database("my_database", initial_data)

Example usage:

initial_data = { "name": "John Doe", "age": 30 }
db = Database("my_database", initial_data)

db.update_key("email", "john@example.com")
db.update_key(123, "This is a number key")

print(db.get_key("name"))  # Output: John Doe
print(db.get_key(123))  # Output: This is a number key

db.delete_key("age")

print(list(db.get_keys()))  # Output: ['name', 'email', '123']
print(db.has_key("age"))  # Output: False

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

About

Simple key-value database made in Python.

Topics

Resources

License

Stars

Watchers

Forks

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy