mongo-malbizer


Namemongo-malbizer JSON
Version 1.0.1 PyPI version JSON
download
home_page
SummaryPython MongoDB CRUD
upload_time2023-05-11 19:46:25
maintainer
docs_urlNone
authorAnderson Souza
requires_python
license
keywords python mongobd crud
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Package for MongoDB CRUD

## For use:
- Install package with PIP;
- Import from mongocrud Mongocrud;
- Configure database settings (location, collection, port...);
- Call object CRUD operations;

## Example:

* For INSERT operation in database:

```python
from mongocrud import MongoCRUD, ObjectId
from datetime import datetime

dbclients = MongoCRUD("mongodb://localhost","mongoteste1")

dbclients.insert("clients", {"_id": "12345", "name":"Anderson 1", "dtupdate": datetime.now()})
dbclients.insert("clients", {"_id": 15 , "name":"Anderson 2", "dtupdate": datetime.now()})
dbclients.insert("clients", {"name":"Anderson 3", "dtupdate": datetime.now()})
dbclients.insert("clients", {"name":"Anderson 4", "dtupdate": datetime.now()})
dbclients.insert("clients", {"name":"Anderson 5", "dtupdate": datetime.now()})
#12 bits/24 bits info as _id
dbclients.insert("clients", {"_id": ObjectId(b'000000000001'), "name":"Anderson 6", "dtupdate": datetime.now()})
```

* For SELECT operation on database (using orderby and direction for sort information):

```python
from mongocrud import MongoCRUD
from datetime import datetime

dbclients = MongoCRUD("mongodb://localhost","mongoteste1")
clients_ordered = dbclients.select("clients", orderby="dtupdate", direction=1)

for client in clients_ordered: print(client)
```

* For SELECT BY _id (select if using ObjectId on _id):

```python
from mongocrud import MongoCRUD
from datetime import datetime

dbclients = MongoCRUD("mongodb://localhost","mongoteste1")

clients = dbclients.select_by_id("clients", "12345", is_objectid=False)
print(clients)
clients = dbclients.select_by_id("clients", 15, is_objectid=False)
print(clients)
clients = dbclients.select_by_id("clients", "64495d9c140992e498f5fcb2", is_objectid=True)
print(clients)
```

* For DELETE query in database:

```python
from mongocrud import MongoCRUD
from datetime import datetime

dbclients = MongoCRUD("mongodb://localhost","mongoteste1")

items = dbclients.delete("clients", {"name": "Anderson 2"})
print("QTD items deleted => ", items)
```

* For DELETE BY _id:

```python
from mongocrud import MongoCRUD, ObjectId
from datetime import datetime

dbclients = MongoCRUD("mongodb://localhost","mongoteste1")

items = dbclients.delete_by_id("clients", "12345", is_objectid=False)
print("QTD items deleted => ", items)

items = dbclients.delete_by_id("clients", "64495d9c140992e498f5fcb1", is_objectid=True)
print("QTD items deleted => ", items)

items = dbclients.delete_by_id("clients", ObjectId(b"000000000001"), is_objectid=False)
print("QTD items deleted => ", items)
```

* for UPDATE row:

```python
from mongocrud import MongoCRUD
from datetime import datetime

dbclients = MongoCRUD("mongodb://localhost","mongoteste1")

dbclients.update_one("clients", "12345", {"name": "teste1", "dtupdate": datetime.now()}, is_objectid=False)
dbclients.update_one("clients", "64496373fe1ef021a556b446", {"name": "teste2", "dtupdate": datetime.now()}, is_objectid=True)
```





            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "mongo-malbizer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,mongobd,crud",
    "author": "Anderson Souza",
    "author_email": "anderson@malbizer.com.br",
    "download_url": "https://files.pythonhosted.org/packages/80/4e/91fc6389d5858197596a6e0b396ebfe98a2eb7967221aad5d39516cc2b5a/mongo_malbizer-1.0.1.tar.gz",
    "platform": null,
    "description": "# Python Package for MongoDB CRUD\r\n\r\n## For use:\r\n- Install package with PIP;\r\n- Import from mongocrud Mongocrud;\r\n- Configure database settings (location, collection, port...);\r\n- Call object CRUD operations;\r\n\r\n## Example:\r\n\r\n* For INSERT operation in database:\r\n\r\n```python\r\nfrom mongocrud import MongoCRUD, ObjectId\r\nfrom datetime import datetime\r\n\r\ndbclients = MongoCRUD(\"mongodb://localhost\",\"mongoteste1\")\r\n\r\ndbclients.insert(\"clients\", {\"_id\": \"12345\", \"name\":\"Anderson 1\", \"dtupdate\": datetime.now()})\r\ndbclients.insert(\"clients\", {\"_id\": 15 , \"name\":\"Anderson 2\", \"dtupdate\": datetime.now()})\r\ndbclients.insert(\"clients\", {\"name\":\"Anderson 3\", \"dtupdate\": datetime.now()})\r\ndbclients.insert(\"clients\", {\"name\":\"Anderson 4\", \"dtupdate\": datetime.now()})\r\ndbclients.insert(\"clients\", {\"name\":\"Anderson 5\", \"dtupdate\": datetime.now()})\r\n#12 bits/24 bits info as _id\r\ndbclients.insert(\"clients\", {\"_id\": ObjectId(b'000000000001'), \"name\":\"Anderson 6\", \"dtupdate\": datetime.now()})\r\n```\r\n\r\n* For SELECT operation on database (using orderby and direction for sort information):\r\n\r\n```python\r\nfrom mongocrud import MongoCRUD\r\nfrom datetime import datetime\r\n\r\ndbclients = MongoCRUD(\"mongodb://localhost\",\"mongoteste1\")\r\nclients_ordered = dbclients.select(\"clients\", orderby=\"dtupdate\", direction=1)\r\n\r\nfor client in clients_ordered: print(client)\r\n```\r\n\r\n* For SELECT BY _id (select if using ObjectId on _id):\r\n\r\n```python\r\nfrom mongocrud import MongoCRUD\r\nfrom datetime import datetime\r\n\r\ndbclients = MongoCRUD(\"mongodb://localhost\",\"mongoteste1\")\r\n\r\nclients = dbclients.select_by_id(\"clients\", \"12345\", is_objectid=False)\r\nprint(clients)\r\nclients = dbclients.select_by_id(\"clients\", 15, is_objectid=False)\r\nprint(clients)\r\nclients = dbclients.select_by_id(\"clients\", \"64495d9c140992e498f5fcb2\", is_objectid=True)\r\nprint(clients)\r\n```\r\n\r\n* For DELETE query in database:\r\n\r\n```python\r\nfrom mongocrud import MongoCRUD\r\nfrom datetime import datetime\r\n\r\ndbclients = MongoCRUD(\"mongodb://localhost\",\"mongoteste1\")\r\n\r\nitems = dbclients.delete(\"clients\", {\"name\": \"Anderson 2\"})\r\nprint(\"QTD items deleted => \", items)\r\n```\r\n\r\n* For DELETE BY _id:\r\n\r\n```python\r\nfrom mongocrud import MongoCRUD, ObjectId\r\nfrom datetime import datetime\r\n\r\ndbclients = MongoCRUD(\"mongodb://localhost\",\"mongoteste1\")\r\n\r\nitems = dbclients.delete_by_id(\"clients\", \"12345\", is_objectid=False)\r\nprint(\"QTD items deleted => \", items)\r\n\r\nitems = dbclients.delete_by_id(\"clients\", \"64495d9c140992e498f5fcb1\", is_objectid=True)\r\nprint(\"QTD items deleted => \", items)\r\n\r\nitems = dbclients.delete_by_id(\"clients\", ObjectId(b\"000000000001\"), is_objectid=False)\r\nprint(\"QTD items deleted => \", items)\r\n```\r\n\r\n* for UPDATE row:\r\n\r\n```python\r\nfrom mongocrud import MongoCRUD\r\nfrom datetime import datetime\r\n\r\ndbclients = MongoCRUD(\"mongodb://localhost\",\"mongoteste1\")\r\n\r\ndbclients.update_one(\"clients\", \"12345\", {\"name\": \"teste1\", \"dtupdate\": datetime.now()}, is_objectid=False)\r\ndbclients.update_one(\"clients\", \"64496373fe1ef021a556b446\", {\"name\": \"teste2\", \"dtupdate\": datetime.now()}, is_objectid=True)\r\n```\r\n\r\n\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python MongoDB CRUD",
    "version": "1.0.1",
    "project_urls": null,
    "split_keywords": [
        "python",
        "mongobd",
        "crud"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d9c2aaac01353b4243ee9eb0cafc274f5f2cbf17d49a96fed4b1b8a45ec7f62",
                "md5": "23c85c2799ac864b5a2d709b05cf528f",
                "sha256": "35b109b4c150737a5793dabcc4298c2ee2fbe48595e4a077b0dfa76fb4abccb7"
            },
            "downloads": -1,
            "filename": "mongo_malbizer-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "23c85c2799ac864b5a2d709b05cf528f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3057,
            "upload_time": "2023-05-11T19:46:22",
            "upload_time_iso_8601": "2023-05-11T19:46:22.137629Z",
            "url": "https://files.pythonhosted.org/packages/8d/9c/2aaac01353b4243ee9eb0cafc274f5f2cbf17d49a96fed4b1b8a45ec7f62/mongo_malbizer-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "804e91fc6389d5858197596a6e0b396ebfe98a2eb7967221aad5d39516cc2b5a",
                "md5": "224b0c2fb367ffb9ef6280ae0eb5ec17",
                "sha256": "ff99563587056142cd5425af66d62a47e00c18a642c90d87eeab2126d8382836"
            },
            "downloads": -1,
            "filename": "mongo_malbizer-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "224b0c2fb367ffb9ef6280ae0eb5ec17",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3115,
            "upload_time": "2023-05-11T19:46:25",
            "upload_time_iso_8601": "2023-05-11T19:46:25.204183Z",
            "url": "https://files.pythonhosted.org/packages/80/4e/91fc6389d5858197596a6e0b396ebfe98a2eb7967221aad5d39516cc2b5a/mongo_malbizer-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-11 19:46:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "mongo-malbizer"
}
        
Elapsed time: 0.06653s