For logging & accessing application data with NoSQL databases (MongoDB & ElasticSearch)
Project description
python-nosql-logger
Installation steps if using MongoDB
pip install pymongo #"pymongo[srv]" or "pymongo[aws]"
pip install python-nosql-logger
Initialize
For synchronous mongo logger
from pynosql_logger.loggers import MongoLogger
connection_string = 'your_mongodb_connection_string'
logger = MongoLogger(connection_string)
For asynchronous mongo logger
from pynosql_logger.async_loggers import AsyncMongoLogger
elastic_url = 'http://127.0.0.1:9200'
logger = AsyncMongoLogger(elastic_url)
Installation steps if using ElasticSearch
pip install requests
pip install python-nosql-logger
Initialize
For synchronous elastic logger
from pynosql_logger.loggers import ElasticLogger
elastic_url = 'http://127.0.0.1:9200'
logger = ElasticLogger(elastic_url)
For asynchronous elastic logger
from pynosql_logger.async_loggers import AsyncElasticLogger
elastic_url = 'http://127.0.0.1:9200'
logger = AsyncElasticLogger(elastic_url)
Add Log
req_json = {
'users': {
'first_name': 'Hitesh',
'last_name': 'Mishra',
'email': 'hiteshmishra708@gmail.com'
}
}
resp = logger.add_log(req_json)
Add Bulk Log
req_json = {
'users': [{
'first_name': 'Test',
'last_name': 'User 1',
'email': 'testuser1@mailnesia.com'
}, {
'first_name': 'Test',
'last_name': 'User 2',
'email': 'testuser2@mailnesia.com'
}]
}
resp = logger.add_log(req_json)
Get Log
req_json = {
'users': {
'first_name': 'Hitesh'
}
}
resp = logger.get_log(req_json)
Get All Logs
req_json = {
'collection': 'users'
}
resp = logger.get_all_logs(req_json)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for python_nosql_logger-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bf2588017ccf0185f9a06012b58ca4853c802e65d944de59d530e8dcfee4cc7 |
|
MD5 | 0ad07837516113b009f2867f1e1eba18 |
|
BLAKE2b-256 | f0e6ce54d496c034e3d791d490ad47906f55d1fc2862b49c00b2d5c8c7abe22c |
Close
Hashes for python_nosql_logger-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 593f822f14bb1189eea90ced99d324bf1e6d967907d55b3a90c55323e33bfc71 |
|
MD5 | c748976b9175cc8b17d09c601b2a0ce8 |
|
BLAKE2b-256 | 72b3d4ae0d3423dc580abf16db369d40cde9b551bdec222dba3807829715b543 |