Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buddhhu/localdb.json
https://github.com/buddhhu/localdb.json
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/buddhhu/localdb.json
- Owner: buddhhu
- License: agpl-3.0
- Created: 2022-02-06T17:37:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-23T14:50:04.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T03:23:11.622Z (about 1 month ago)
- Language: Python
- Size: 40 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## [localdb.json](https://github.com/buddhhu/localdb.json)
**A helper script for easy handling of JSON file as database in local storage.**---
### Installation
- `pip install localdb.json`---
### Usage#### Creating instance
```python
from localdb import Databasedb = Database("example.json")
```---
#### Saving some data
This creates a key with the given value. It will overwrite existing key's value. Always returns `True`.
```python
db.set("TEST", "VALUE")
>>> True
```---
#### Getting saved data
Returns value of requested key if it exists or will return `None`.
```python
db.get("TEST")
>>> VALUE
```---
#### Renaming a key
Renames an existing key to another. Returns `True` if it exists or will return `None`.
```python
db.rename("TEST", "Test")
>>> True
```---
#### Deleting a key
Deletes key and value from database. Returns `True` if it exists or will return `None`.
```python
db.delete("Test")
>>> True
```---
#### Database size
Size of database file is returned in bytes.
```python
db.size
>>> 42
```---
### Issues ?
Open issues or ask [here](https://t.me/botsrealm)### Contributing
Pull requests are welcome.### License
Licensed under [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) v3.### Credits
- [Me](https://github.com/buddhhu)