# HadiDB
HadiDB is a lightweight, extremely horizontally scalable database written in Python
# How to install hadidb
```python
pip install hadidb
```
## Create User HadiDB
Creates a new user with the `example` username `admin` and `example` password `admin` using `createUser()`. It then authenticates the same user by calling the `authentication()` method.
```python
from HadiDB.operation import User
user = User("admin", "admin")
user.createUser() # Creating a new user in the HadiDB
user.authentication() # Authenticating the HadiDB user
```
##### Result:
```josn
{'status': 200, 'message': 'Database user Created'}
```
## Create Databse , Collection and Schema
This code sets up user credentials and a schema for a database collection. It initializes a database operation using the `Operation` class with the specified `username`, `password`, `database`, and `collection`. Finally, it inserts the provided `data` into the collection and stores the result.
```python
from HadiDB.operation import Operation
username = "admin"
password = "admin"
database = "mefiz.com"
collection = "authUser"
schema = {
"username":"Unique",
"password":"Hash",
"cnic":"Unique",
"picture":"Image",
"bio":"Text"
}
db = Operation(username,password,database,collection)
db.create_database(schema)
```
## Insert Data
Insert Data into the Collection use `db.insert(data)` inserts the `data` into the specified database collection.
```python
from HadiDB.operation import Operation
username = "admin"
password = "admin"
database = "mefiz.com"
collection = "authUser"
db = Operation(username,password,database,collection)
data = {
"username":"hadidb",
"password":"12345",
"cnic":"123232442",
"picture":"user/my/hadidb.jpg",
"bio":"HadiDB is the Best ;)"
}
result = db.insert(data)
print(result)
```
##### Result:
```json
{
'status': 200,
'message': 'Data insert successfully',
'data': {
'username': 'hadidb',
'password': '12345',
'cnic': '123232442',
'picture': 'user/my/hadidb.jpg',
'bio': 'HadiDB is the Best ;)',
'id': 1
}
}
```
## Update Data
Update Data `db.update(1, update_data)` updates the record with the ID `1` in the database using the provided `update_data`.
```python
from HadiDB.operation import Operation
username = "admin"
password = "admin"
database = "mefiz.com"
collection = "authUser"
db = Operation(username,password,database,collection)
update_data = {
"username": "hadidb_update",
"password": "123455",
"cnic": "1232324423",
"picture": "user/my/hadidb1.jpg",
"bio": "HadiDB is the Best ;) update bio"
}
result = db.update(1,update_data)
print(result)
```
##### Result:
```json
{
'status': 200,
'message': 'Data Update successfully',
'data': {
'username': 'hadidb_update',
'password': '123455',
'cnic': '1232324423',
'picture': 'user/my/hadidb1.jpg',
'bio': 'HadiDB is the Best ;) update bio',
'id': 1
}
}
```
## GetByID
The unique identifier (ID) of the document you want to retrieve specific object or an error if the document does not exist.
```python
result = db.getbyID(1)
print(result)
```
## Get All Object
The `getAll` method retrieves all documents from the specified collection in the database.
```python
result = db.getAll()
print(result)
```
## GetByKey
The `getbykey` method retrieves all documents from the database where the specified key-value pair matches. `Not Support multi keys values pairs`
```python
result = db.getbykey({
"username":"momin"
})
print(result)
```
## GetByKeys
The getbykeys function uses an implicit `AND (&&)`operation. Both conditions `Example (cnic and bio)` if matched key values in the database then return the matched object.
```python
result = db.getbykeys({
"cnic":"123232442",
"bio":"HadiDB is the Best ;) update bio"
})
print(result)
```
## Count
The `count` method returns the total number of documents (or objects) present in the specified collection in the database.
```python
result = db.count()
print(result)
```
##### Result:
```json
{'status': 200, 'count': 1}
```
## GeyByKeyCount
The `getbykeyCount` method counts the number of documents in the collection where the specified key-value pair matches.
```python
result = db.getbykeyCount({
"username":"momin"
})
```
## Delete
Deletes a document from the database by its unique identifier (`id`)
```python
result = db.delete(1)
print(result)
```
##### Reuslt:
```json
{'status': 200, 'message': 'data delete successful'}
```
## Get All Database
Retrieves all available databases by using the `get_database()` method of the `Configuration` class
```python
from HadiDB.operation import Configuration
print(Configuration().get_database())
```
## Get All Collection
Retrieves all collections from a specific database using the `get_collection() ` method of the `Configuration` class.
```python
from HadiDB.operation import Configuration
database = "mefiz.com"
print(Configuration(database).get_collection())
```
## Get Schema of Specfic Collection
Return Schema of a specific collection by using ` get_schema() `method from the `Configuration` class.
```python
from HadiDB.operation import Configuration
database = "mefiz.com"
collection = "authUser"
print(Configuration(database,collection).get_schema())
```
## Delete Collection
Deletes a specific collection from a database using the `deleteCollection()` method of the `DatabaseDeletionService` class.
```python
from HadiDB.operation import DatabaseDeletionService
db = DatabaseDeletionService(username,password,database,collection)
print(db.deleteCollection())
```
## Delete Database
Deletes Database using the `deleteDatabase()` method of the `DatabaseDeletionService` class.
```python
from HadiDB.operation import DatabaseDeletionService
db = DatabaseDeletionService(username,password,database,collection)
print(db.deleteDatabase())
```
##### GitHub : https://github.com/MominIqbal-1234/hadidb
##### Check Our Site : https://mefiz.com/about </br>
##### Developed by : Momin Iqbal
Raw data
{
"_id": null,
"home_page": null,
"name": "HadiDB",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, pyjsondbpython database, hadidb, python hadidb, hadidb django",
"author": "mominiqbal1234",
"author_email": "<mominiqbal1214@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/5d/ce/d3ed8f4916e7a48c03514f085625fd54a751b0d9787f91695661d6d7e13b/hadidb-0.1.1.tar.gz",
"platform": null,
"description": "\n# HadiDB\nHadiDB is a lightweight, extremely horizontally scalable database written in Python\n\n# How to install hadidb\n\n```python\npip install hadidb\n```\n\n## Create User HadiDB\nCreates a new user with the `example` username `admin` and `example` password `admin` using `createUser()`. It then authenticates the same user by calling the `authentication()` method. \n\n```python\nfrom HadiDB.operation import User\nuser = User(\"admin\", \"admin\")\nuser.createUser() # Creating a new user in the HadiDB\nuser.authentication() # Authenticating the HadiDB user\n```\n##### Result:\n\n```josn\n{'status': 200, 'message': 'Database user Created'}\n```\n\n\n## Create Databse , Collection and Schema\nThis code sets up user credentials and a schema for a database collection. It initializes a database operation using the `Operation` class with the specified `username`, `password`, `database`, and `collection`. Finally, it inserts the provided `data` into the collection and stores the result.\n\n```python\nfrom HadiDB.operation import Operation\n\nusername = \"admin\"\npassword = \"admin\"\ndatabase = \"mefiz.com\"\ncollection = \"authUser\"\n\nschema = {\n \"username\":\"Unique\",\n \"password\":\"Hash\",\n \"cnic\":\"Unique\",\n \"picture\":\"Image\",\n \"bio\":\"Text\"\n}\ndb = Operation(username,password,database,collection)\ndb.create_database(schema)\n```\n## Insert Data\nInsert Data into the Collection use `db.insert(data)` inserts the `data` into the specified database collection.\n```python\nfrom HadiDB.operation import Operation\n\nusername = \"admin\"\npassword = \"admin\"\ndatabase = \"mefiz.com\"\ncollection = \"authUser\"\n\n\ndb = Operation(username,password,database,collection)\n\ndata = {\n \"username\":\"hadidb\",\n \"password\":\"12345\",\n \"cnic\":\"123232442\",\n \"picture\":\"user/my/hadidb.jpg\",\n \"bio\":\"HadiDB is the Best ;)\"\n}\n\n\nresult = db.insert(data)\nprint(result)\n```\n##### Result:\n```json\n{\n'status': 200, \n'message': 'Data insert successfully',\n'data': {\n 'username': 'hadidb', \n 'password': '12345', \n 'cnic': '123232442', \n 'picture': 'user/my/hadidb.jpg', \n 'bio': 'HadiDB is the Best ;)',\n 'id': 1\n }\n}\n\n\n```\n\n## Update Data\nUpdate Data `db.update(1, update_data)` updates the record with the ID `1` in the database using the provided `update_data`.\n```python\nfrom HadiDB.operation import Operation\n\nusername = \"admin\"\npassword = \"admin\"\ndatabase = \"mefiz.com\"\ncollection = \"authUser\"\n\n\ndb = Operation(username,password,database,collection)\n\n\nupdate_data = { \n \"username\": \"hadidb_update\",\n \"password\": \"123455\",\n \"cnic\": \"1232324423\",\n \"picture\": \"user/my/hadidb1.jpg\",\n \"bio\": \"HadiDB is the Best ;) update bio\" \n}\n\nresult = db.update(1,update_data)\nprint(result)\n```\n##### Result:\n```json\n{\n 'status': 200, \n 'message': 'Data Update successfully',\n 'data': {\n 'username': 'hadidb_update', \n 'password': '123455', \n 'cnic': '1232324423', \n 'picture': 'user/my/hadidb1.jpg', \n 'bio': 'HadiDB is the Best ;) update bio', \n 'id': 1\n }\n}\n```\n\n\n## GetByID\nThe unique identifier (ID) of the document you want to retrieve specific object or an error if the document does not exist.\n\n```python\nresult = db.getbyID(1)\nprint(result)\n```\n\n## Get All Object\nThe `getAll` method retrieves all documents from the specified collection in the database.\n```python\nresult = db.getAll()\nprint(result)\n```\n\n## GetByKey\nThe `getbykey` method retrieves all documents from the database where the specified key-value pair matches. `Not Support multi keys values pairs`\n```python\nresult = db.getbykey({\n \"username\":\"momin\"\n })\nprint(result)\n```\n\n## GetByKeys\n\nThe getbykeys function uses an implicit `AND (&&)`operation. Both conditions `Example (cnic and bio)` if matched key values in the database then return the matched object.\n\n```python\nresult = db.getbykeys({\n \"cnic\":\"123232442\",\n \"bio\":\"HadiDB is the Best ;) update bio\"\n})\nprint(result)\n```\n\n\n## Count \nThe `count` method returns the total number of documents (or objects) present in the specified collection in the database.\n\n```python\nresult = db.count()\nprint(result)\n```\n##### Result:\n```json\n{'status': 200, 'count': 1}\n```\n\n## GeyByKeyCount\nThe `getbykeyCount` method counts the number of documents in the collection where the specified key-value pair matches.\n```python\nresult = db.getbykeyCount({\n \"username\":\"momin\"\n })\n```\n\n\n\n\n## Delete \nDeletes a document from the database by its unique identifier (`id`)\n\n```python\nresult = db.delete(1)\nprint(result)\n```\n##### Reuslt:\n```json\n{'status': 200, 'message': 'data delete successful'}\n```\n\n\n## Get All Database \nRetrieves all available databases by using the `get_database()` method of the `Configuration` class\n```python\nfrom HadiDB.operation import Configuration\n\nprint(Configuration().get_database())\n```\n## Get All Collection\nRetrieves all collections from a specific database using the `get_collection() ` method of the `Configuration` class.\n\n```python\nfrom HadiDB.operation import Configuration\n\ndatabase = \"mefiz.com\"\nprint(Configuration(database).get_collection())\n```\n## Get Schema of Specfic Collection\nReturn Schema of a specific collection by using ` get_schema() `method from the `Configuration` class.\n```python\nfrom HadiDB.operation import Configuration\ndatabase = \"mefiz.com\"\ncollection = \"authUser\"\nprint(Configuration(database,collection).get_schema())\n```\n\n\n\n## Delete Collection\nDeletes a specific collection from a database using the `deleteCollection()` method of the `DatabaseDeletionService` class.\n```python\nfrom HadiDB.operation import DatabaseDeletionService\n\ndb = DatabaseDeletionService(username,password,database,collection)\nprint(db.deleteCollection())\n```\n## Delete Database \nDeletes Database using the `deleteDatabase()` method of the `DatabaseDeletionService` class.\n```python\nfrom HadiDB.operation import DatabaseDeletionService\n\ndb = DatabaseDeletionService(username,password,database,collection)\nprint(db.deleteDatabase())\n```\n\n##### GitHub : https://github.com/MominIqbal-1234/hadidb\n##### Check Our Site : https://mefiz.com/about </br>\n##### Developed by : Momin Iqbal\n\n \n",
"bugtrack_url": null,
"license": null,
"summary": "HadiDB is a lightweight, extremely horizontally scalable database written in Python.",
"version": "0.1.1",
"project_urls": null,
"split_keywords": [
"python",
" pyjsondbpython database",
" hadidb",
" python hadidb",
" hadidb django"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "43abf13f5284e33b7046acedfbe940dfdb262eb90a6afc4ba1c72c5f8f3243f2",
"md5": "a453c59e46c97f4482a034fcae0d47c1",
"sha256": "5b46cf8996f41fde35f38f00fc8c9d208ac286e083aeae1491dbd30db77a4072"
},
"downloads": -1,
"filename": "HadiDB-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a453c59e46c97f4482a034fcae0d47c1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19964,
"upload_time": "2024-09-18T13:06:28",
"upload_time_iso_8601": "2024-09-18T13:06:28.966368Z",
"url": "https://files.pythonhosted.org/packages/43/ab/f13f5284e33b7046acedfbe940dfdb262eb90a6afc4ba1c72c5f8f3243f2/HadiDB-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5dced3ed8f4916e7a48c03514f085625fd54a751b0d9787f91695661d6d7e13b",
"md5": "fd5eedac1484a2d8901c7528511226d8",
"sha256": "26722c3e411aaff417761bb4c0a55ced743b482bbd4a141dadac408d3b1b26b9"
},
"downloads": -1,
"filename": "hadidb-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "fd5eedac1484a2d8901c7528511226d8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12460,
"upload_time": "2024-09-18T13:06:31",
"upload_time_iso_8601": "2024-09-18T13:06:31.094460Z",
"url": "https://files.pythonhosted.org/packages/5d/ce/d3ed8f4916e7a48c03514f085625fd54a751b0d9787f91695661d6d7e13b/hadidb-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-18 13:06:31",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "hadidb"
}