Name | DBDictionary JSON |
Version |
0.1.1
JSON |
| download |
home_page | |
Summary | A dictionary-like interface for using databases |
upload_time | 2023-09-19 18:49:19 |
maintainer | |
docs_url | None |
author | shashstormer |
requires_python | |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# DB Dictionary
## Description :
This is a module which has been designed to make it easier to work with databases
in python using a dictionary like interface.
## Installation :
`pip install DBDictionary`
## Usage MongoDB :
```python
from DBDictionary import MongoDB_Dict
my_db_dict = MongoDB_Dict("my_db_name", "my_collection_name", "my_key_field", "my_connection_string")
# The connection string is optional and will default to
# "mongodb://localhost:27017/" if not provided here and not in the ENV var also
my_db_dict["my_key"] = {"my_key_field": "my_key",
"other data": "my_value"} # This will insert a new document into the collection
your_value = my_db_dict["my_key"] # This will return "my_value", the value in the database
print(your_value) # This will print {"my_key_field": "my_key", "other data": "my_value"}
del my_db_dict["my_key"] # This will delete the document from the collection
# now trying to retrive the value will raise a KeyError ,
# but you can use the "get" method like you do in a dictionary as usual
your_value = my_db_dict.get("my_key", "default_value") # This will return "default_value"
print(your_value) # This will print "default_value"
your_value = my_db_dict["my_key"] # This will raise a KeyError
# editing and updating a document :
your_value["other data"] = "my_new_value" # This will edit the value in the memory
my_db_dict.update(your_value) # This will update the document in the database
# When you edit a dictionary like this :
my_db_dict["my_key"][
"other data"] = "my_new_value" # This will have no effect on the database and any changes will be lost
```
Raw data
{
"_id": null,
"home_page": "",
"name": "DBDictionary",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "shashstormer",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/48/0c/7c99c76bb7b0beac5d568c73983d9e48907984c8d65a60469334cd5da7fb/DBDictionary-0.1.1.tar.gz",
"platform": null,
"description": "# DB Dictionary\r\n\r\n## Description :\r\nThis is a module which has been designed to make it easier to work with databases \r\nin python using a dictionary like interface.\r\n\r\n## Installation :\r\n`pip install DBDictionary`\r\n\r\n## Usage MongoDB :\r\n\r\n```python\r\nfrom DBDictionary import MongoDB_Dict\r\n\r\nmy_db_dict = MongoDB_Dict(\"my_db_name\", \"my_collection_name\", \"my_key_field\", \"my_connection_string\")\r\n# The connection string is optional and will default to \r\n# \"mongodb://localhost:27017/\" if not provided here and not in the ENV var also\r\nmy_db_dict[\"my_key\"] = {\"my_key_field\": \"my_key\",\r\n \"other data\": \"my_value\"} # This will insert a new document into the collection\r\nyour_value = my_db_dict[\"my_key\"] # This will return \"my_value\", the value in the database\r\nprint(your_value) # This will print {\"my_key_field\": \"my_key\", \"other data\": \"my_value\"}\r\ndel my_db_dict[\"my_key\"] # This will delete the document from the collection\r\n# now trying to retrive the value will raise a KeyError ,\r\n# but you can use the \"get\" method like you do in a dictionary as usual\r\nyour_value = my_db_dict.get(\"my_key\", \"default_value\") # This will return \"default_value\"\r\nprint(your_value) # This will print \"default_value\"\r\nyour_value = my_db_dict[\"my_key\"] # This will raise a KeyError\r\n\r\n# editing and updating a document :\r\nyour_value[\"other data\"] = \"my_new_value\" # This will edit the value in the memory\r\nmy_db_dict.update(your_value) # This will update the document in the database\r\n\r\n# When you edit a dictionary like this :\r\nmy_db_dict[\"my_key\"][\r\n \"other data\"] = \"my_new_value\" # This will have no effect on the database and any changes will be lost\r\n```\r\n",
"bugtrack_url": null,
"license": "",
"summary": "A dictionary-like interface for using databases",
"version": "0.1.1",
"project_urls": {
"GitHub": "https://github.com/shashstormer/db_dict"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "52507ecb725882eec348a783e9c78a6c3409f04591e3df508ef9ce8b67e60f9b",
"md5": "6b492e080f170f065adf001895f7c663",
"sha256": "04698c3fdb6f544ed69044fcd894fc5d00bf6f4920b5ab8404353ecec1f6a25a"
},
"downloads": -1,
"filename": "DBDictionary-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6b492e080f170f065adf001895f7c663",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6533,
"upload_time": "2023-09-19T18:49:18",
"upload_time_iso_8601": "2023-09-19T18:49:18.421526Z",
"url": "https://files.pythonhosted.org/packages/52/50/7ecb725882eec348a783e9c78a6c3409f04591e3df508ef9ce8b67e60f9b/DBDictionary-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "480c7c99c76bb7b0beac5d568c73983d9e48907984c8d65a60469334cd5da7fb",
"md5": "201eca14921a75edd7ac48369c1f818e",
"sha256": "9a1ab03f40dd1e37d1760dc7c44f07a2f34c5dd98998cceb20119c20dcc7051a"
},
"downloads": -1,
"filename": "DBDictionary-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "201eca14921a75edd7ac48369c1f818e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5569,
"upload_time": "2023-09-19T18:49:19",
"upload_time_iso_8601": "2023-09-19T18:49:19.847088Z",
"url": "https://files.pythonhosted.org/packages/48/0c/7c99c76bb7b0beac5d568c73983d9e48907984c8d65a60469334cd5da7fb/DBDictionary-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-19 18:49:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "shashstormer",
"github_project": "db_dict",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "dbdictionary"
}