Mango: simple MongoDb wrapper
Project description
Mango
=====
A Simple wrapper module for Mongo sit on top of PyMongo.
Installation
------------
To install ``mango`` lib: ``pip install python-mango``.
Usage
-----
To import module: ``import mango``.
Sample:
.. raw:: html
.. code:: python
import mango
uri = "mongodb://user:pwd@localhost:port/database"
mango.init_db(uri)
# To get database object
db = mango.mgdb
# To get table object
mytable = mango.get_table('mytable')
# Select rows
rows = mango.select('mytable')
rows = mango.select('mytable', { "qty": { "$gt": 4 } })
.. raw:: html
Availabe functions
------------------
- `init_db`_
- `get_table`_
- `select`_
- `insert`_
- `update`_
- `delete`_
init\_db
--------
To initialize MongoDb Connection.
Parameter:
``uri``: MongoDb URI
get\_table
----------
Get the MongoDb Table object.
Parameter:
- ``table_name``: Table name
select
------
Query record(s) from table.
Parameters:
- ``table_name``: Table name
- ``_filter``: MongoDb filter object
- ``is_many``: Use ``find`` or ``find_one``. Default is ``False`` which
means ``find_one`` will be used.
- ``**kwargs``: ``KwArgs`` which will be pass to pymongo function
insert
------
Insert record(s) to table.
Parameters: - ``table_name``: Table name - ``_value``: Value that will
be inserted - ``is_many``: ``insert_one`` or ``insert_many``. Default is
``False`` (means ``insert_one``). - ``**kwargs``: ``KwArgs`` will be
pass to pymongo function
update
------
Update record(s) to table.
Parameters:
- ``table_name``: Table name
- ``_filter``: MongoDb filter object
- ``_value``: Value that will be updated
- ``is_many``: ``update_one`` or ``update_many``. Default is ``False``
(means ``update_one``).
- ``_operation``: MongoDb update operation. Default is ``$set``.
- ``**kwargs``: ``KwArgs`` will be pass to pymongo function.
delete
------
Delete record(s) to table.
Parameters:
- ``table_name``: Table name
- ``_filter``: MongoDb filter object
- ``is_many``: ``delete_one`` or ``delete_many``. Default is ``False``
(means ``delete_one``).
- ``**kwargs``: ``KwArgs`` will be pass to pymongo function.
.. _``init_db``: #init_db
.. _``get_table``: #get_table
.. _``select``: #select
.. _``insert``: #insert
.. _``update``: #update
.. _``delete``: #delete
=====
A Simple wrapper module for Mongo sit on top of PyMongo.
Installation
------------
To install ``mango`` lib: ``pip install python-mango``.
Usage
-----
To import module: ``import mango``.
Sample:
.. raw:: html
.. code:: python
import mango
uri = "mongodb://user:pwd@localhost:port/database"
mango.init_db(uri)
# To get database object
db = mango.mgdb
# To get table object
mytable = mango.get_table('mytable')
# Select rows
rows = mango.select('mytable')
rows = mango.select('mytable', { "qty": { "$gt": 4 } })
.. raw:: html
Availabe functions
------------------
- `init_db`_
- `get_table`_
- `select`_
- `insert`_
- `update`_
- `delete`_
init\_db
--------
To initialize MongoDb Connection.
Parameter:
``uri``: MongoDb URI
get\_table
----------
Get the MongoDb Table object.
Parameter:
- ``table_name``: Table name
select
------
Query record(s) from table.
Parameters:
- ``table_name``: Table name
- ``_filter``: MongoDb filter object
- ``is_many``: Use ``find`` or ``find_one``. Default is ``False`` which
means ``find_one`` will be used.
- ``**kwargs``: ``KwArgs`` which will be pass to pymongo function
insert
------
Insert record(s) to table.
Parameters: - ``table_name``: Table name - ``_value``: Value that will
be inserted - ``is_many``: ``insert_one`` or ``insert_many``. Default is
``False`` (means ``insert_one``). - ``**kwargs``: ``KwArgs`` will be
pass to pymongo function
update
------
Update record(s) to table.
Parameters:
- ``table_name``: Table name
- ``_filter``: MongoDb filter object
- ``_value``: Value that will be updated
- ``is_many``: ``update_one`` or ``update_many``. Default is ``False``
(means ``update_one``).
- ``_operation``: MongoDb update operation. Default is ``$set``.
- ``**kwargs``: ``KwArgs`` will be pass to pymongo function.
delete
------
Delete record(s) to table.
Parameters:
- ``table_name``: Table name
- ``_filter``: MongoDb filter object
- ``is_many``: ``delete_one`` or ``delete_many``. Default is ``False``
(means ``delete_one``).
- ``**kwargs``: ``KwArgs`` will be pass to pymongo function.
.. _``init_db``: #init_db
.. _``get_table``: #get_table
.. _``select``: #select
.. _``insert``: #insert
.. _``update``: #update
.. _``delete``: #delete
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
python-mango-0.1.3.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for python_mango-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52420859576737d0412437b5b2b2bf34370d768742cd7e252e220eae63cafeee |
|
MD5 | 1c52d70413aa5672d4c73ab227d05140 |
|
BLAKE2b-256 | d9b32f3ffad17d398cfd69c01d6838577f9c5603707b10c9e26605705ff1b051 |