a3mongo is a simple wrapper around pymongo to make it easier to use.
Project description
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'})
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
a3mongo-0.3.0.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file a3mongo-0.3.0.tar.gz
.
File metadata
- Download URL: a3mongo-0.3.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a79ff5c9606b25a2077438749a21f2ff54a701401b2867c4aafca71a6a73bc59
|
|
MD5 |
f10effdfa7b04fa71fb54f3c546a3477
|
|
BLAKE2b-256 |
a11e355b1e43d4f693fe673ba10781c7b6701ccf2f3cc0178c1e704e1cb343d4
|
File details
Details for the file a3mongo-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: a3mongo-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
90a9b13fbfba971606117bba90a4fd93f174b1ec7c5355f5d10b11e73b63e531
|
|
MD5 |
798c74b92ac3b3a9bc7f946c61b0474f
|
|
BLAKE2b-256 |
2aa936ffa0111ff3edf627d5073a00fcc37c265e20539e0c27455fae60c442fb
|