a3mongo
English | 简体中文
a3mongo is a simple wrapper around pymongo to make it easier to use.
1. Introduction
- Multiple MongoDB services can be configured at the same time.
- Some commonly used methods have been encapsulated.
2. Usage
Install
pip install a3mongo
Examples
CONF = {
'site_a': {
"host": "127.0.0.1",
"port": 27017,
"username": "username",
"password": "password",
"authSource": "site_a",
"authMechanism": "SCRAM-SHA-256"
},
'site_b': {
"host": "127.0.0.1",
"port": 27018,
"username": "username",
"password": "password",
"authSource": "site_b",
"authMechanism": "SCRAM-SHA-256"
}
}
from a3mongo import MongoClientFactory, MongoTable
class SiteUser(MongoTable):
table_name = 'site_user'
db_conf_name = 'site_a'
if __name__ == '__main__':
MongoClientFactory.init_mongo_clients(conf=CONF)
site_user = SiteUser()
site_user.create_table()
site_user.create_index_list(['name', 'gender', 'email'])
site_user.upsert_many([
{'name': 'Alice', 'gender': 'female', 'email': 'alice@example.com'},
{'name': 'Bob', 'gender':'male', 'email': 'bob@example.com'},
{'name': 'Charlie', 'gender': 'male', 'email': 'charlie@example.com'},
])
male_users = site_user.find({'gender':'male'})
Metadata
Release files for a3mongo 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| a3mongo-0.3.0.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| a3mongo-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / a3mongo-0.3.0.tar.gz
| Download URL | a3mongo-0.3.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a79ff5c9606b25a2077438749a21f2ff54a701401b2867c4aafca71a6a73bc59
|
|
BLAKE2b-256 checksum How to use checksums |
a11e355b1e43d4f693fe673ba10781c7b6701ccf2f3cc0178c1e704e1cb343d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Release files / a3mongo-0.3.0-py3-none-any.whl
| Download URL | a3mongo-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90a9b13fbfba971606117bba90a4fd93f174b1ec7c5355f5d10b11e73b63e531
|
|
BLAKE2b-256 checksum How to use checksums |
2aa936ffa0111ff3edf627d5073a00fcc37c265e20539e0c27455fae60c442fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|