No project description provided
Project description
A flat file database for json objects.
Home-page: https://github.com/gunthercox/jsondb
Author: Gunther Cox
Author-email: gunthercx@gmail.com
License: BSD
Description: # jsondb
[![Build Status][travis-image]][travis-build]
[](https://badge.fury.io/py/jsondatabase)
This is a utility for managing content in a database which stores
content in JSON format.
## Installation
This package can be installed from [PyPi](https://pypi.python.org/pypi/jsondatabase) by running:
```bash
pip install jsondatabase
```
Note, the package name and the import name are different.
Import the package using `import jsondb`.
## Usage
```python
from jsondb.db import Database
db = Database("mydata.db")
```
The database has an attribute which works similar to
[jQuery's `data`][jquery-data] attribute.
```python
# Getting all data
db = Database("mydata.db")
print(db.data())
```
```python
# Getting a stored value
db = Database("mydata.db")
print(db.data(key="user_count"))
```
**It is important to note that a key will be created regardless of whether it
exists as long as a value is provided.** The database has the same functionality
as a dictionary.
```python
# Setting a value
db = Database("mydata.db")
db.data(key="user_count", value=241)
```
```python
# Passing in a dictionary value
db = Database("mydata.db")
data = {
"user_id": 234565,
"user_name": "AwesomeUserName",
"is_moderator": True,
}
db.data(dictionary=data)
```
```python
# Deleting a value
db = Database("mydata.db")
db.delete("my_key")
```
The database also supports a dictionary-like syntax for retrieving, setting, and
removing values.
```python
db = Database("mydata.db")
# Retrieving a value
value = db["key"]
# Setting a value
db["key"] = value
# Removing a key
del db["key"]
# Checking if a key exists
"key" in db
```
## Performance
If performance is an issue with large databases then the `python-cjson` module
can be installed. jsondb will automatically detect this and use cjson instead.
[jquery-data]: http://api.jquery.com/data/
[travis-build]: https://travis-ci.org/gunthercox/jsondb
[travis-image]: https://travis-ci.org/gunthercox/jsondb.svg
History
-------
`See release notes
<https://github.com/gunthercox/jsondb/releases>`_
Keywords: jsondb
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Home-page: https://github.com/gunthercox/jsondb
Author: Gunther Cox
Author-email: gunthercx@gmail.com
License: BSD
Description: # jsondb
[![Build Status][travis-image]][travis-build]
[](https://badge.fury.io/py/jsondatabase)
This is a utility for managing content in a database which stores
content in JSON format.
## Installation
This package can be installed from [PyPi](https://pypi.python.org/pypi/jsondatabase) by running:
```bash
pip install jsondatabase
```
Note, the package name and the import name are different.
Import the package using `import jsondb`.
## Usage
```python
from jsondb.db import Database
db = Database("mydata.db")
```
The database has an attribute which works similar to
[jQuery's `data`][jquery-data] attribute.
```python
# Getting all data
db = Database("mydata.db")
print(db.data())
```
```python
# Getting a stored value
db = Database("mydata.db")
print(db.data(key="user_count"))
```
**It is important to note that a key will be created regardless of whether it
exists as long as a value is provided.** The database has the same functionality
as a dictionary.
```python
# Setting a value
db = Database("mydata.db")
db.data(key="user_count", value=241)
```
```python
# Passing in a dictionary value
db = Database("mydata.db")
data = {
"user_id": 234565,
"user_name": "AwesomeUserName",
"is_moderator": True,
}
db.data(dictionary=data)
```
```python
# Deleting a value
db = Database("mydata.db")
db.delete("my_key")
```
The database also supports a dictionary-like syntax for retrieving, setting, and
removing values.
```python
db = Database("mydata.db")
# Retrieving a value
value = db["key"]
# Setting a value
db["key"] = value
# Removing a key
del db["key"]
# Checking if a key exists
"key" in db
```
## Performance
If performance is an issue with large databases then the `python-cjson` module
can be installed. jsondb will automatically detect this and use cjson instead.
[jquery-data]: http://api.jquery.com/data/
[travis-build]: https://travis-ci.org/gunthercox/jsondb
[travis-image]: https://travis-ci.org/gunthercox/jsondb.svg
History
-------
`See release notes
<https://github.com/gunthercox/jsondb/releases>`_
Keywords: jsondb
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsondatabase-0.1.7.tar.gz
(6.5 kB
view details)
Built Distribution
File details
Details for the file jsondatabase-0.1.7.tar.gz
.
File metadata
- Download URL: jsondatabase-0.1.7.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
994a34203d2c6bf224dc96ab271d42059bd1b9e247a085f6d786e0e8e68a1a81
|
|
MD5 |
692d367502519110046bfca17632fe87
|
|
BLAKE2b-256 |
3eaed0d402b69eca49ab36ebb80bd90ebf8e3060ceae4c4b383e36119aaa0628
|
File details
Details for the file jsondatabase-0.1.7-py2.py3-none-any.whl
.
File metadata
- Download URL: jsondatabase-0.1.7-py2.py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0474dfacd515268185f2ad70bbdbb5cea7255629e7d0060d4526613dd35a488e
|
|
MD5 |
25b52568fd1781de249852abcd670b5a
|
|
BLAKE2b-256 |
f3257b4f6d7536b98bc484b429568282496740bec1b2813cb718180585526d4a
|