Skip to main content

MangoMango

Basics

Usage

Connecting to MongoDB

To connect to a MongoDB instance, create a MangoMango client:

from mangomango import MangoMango

client = MangoMango(host="localhost", port=27017)

Creating a Database

To create or get a database, use the get_database method:

db = client.get_database("mydatabase")

Defining a Table

To define a table, use the table decorator on a Pydantic model. The type will not change, it will just register a table with this Model. To get the table, use get_table:

@db.table(collection="users", primary_key="id")
class User(BaseModel):
    id: int
    username: str
    email: str

UserTable = db.get_table("users")

Inserting Data

To insert data into a table:

user = User(id=0, username="john_doe", email="john@example.com")
UserTable.insert(user)

Querying Data

To query data from a table:

user = UserTable.find({"username": "john_doe"})
print(user.username, user.email)

Updating Data

To update data in a table, use the update() method. The first argument is the primary key of the object, it can also be the object itself.

UserTable.update(john.id, {"$set": {"email": "john_new@example.com"}})

You can also edit the object and re-push it with the same primary key. use push() method that insert if there is no object with the same primary key, else it remove and then insert

john.email = "john_new@example.com"
UserTable.push(john)

Deleting Data

To delete one data from a table, use remove() method. Can take either primary key or object as first argument:

UserTable.remove(john.id)

Bulk Insert

To insert multiple objects:

users = [
    User(id=1, username="alice", email="alice@example.com"),
    User(id=2, username="bob", email="bob@example.com")
]
UserTable.insert_many_iter(users)

Bulk Update

To update multiple objects:

UserTable.update_many({"username": {"$in": ["alice", "bob"]}}, {"$set": {"active": True}})

Bulk Delete

To delete multiple objects:

UserTable.remove_many({"username": {"$in": ["alice", "bob"]}})

the doc is not finished

Metadata

Release files for mangomango 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mangomango 0.1.3
File Size Uploaded Provenance Actions
mangomango-0.1.3.tar.gz 3.7 kB Without provenance Details for mangomango-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mangomango 0.1.3
File Interpreter ABI Platform Actions
mangomango-0.1.3-py3-none-any.whl Python 3 none any Details for mangomango-0.1.3-py3-none-any.whl

Total release size: 7.8 kB

Release files / mangomango-0.1.3.tar.gz

Download URL mangomango-0.1.3.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9d7ab7dafcec6e8b651a3fb9c94a167c2f0dad56bcb01636ab2193e650f43c42
BLAKE2b-256 checksum
How to use checksums
830fcca455eda74b657265300117a6cb2f445c72c34e38d2fde873479079dbff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.13.1 Windows/10

Release files / mangomango-0.1.3-py3-none-any.whl

Download URL mangomango-0.1.3-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48624836b90d0f0c196b0aa15fc9961394d33d215db41247978632cb9821f51e
BLAKE2b-256 checksum
How to use checksums
b5673d6e25560657ac911a060aa9338398aca245c36f52de6bd0c79415c311ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.13.1 Windows/10

Security for mangomango 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page