Metadata-Version: 1.1
Name: sofart
Version: 0.3.6
Summary: Python in-memory embedded and non-relationnal database
Home-page: UNKNOWN
Author: toxinu
Author-email: toxinu@gmail.com
License: Copyright (c) 2020, toxinu
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <organization> nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description: ======
        Sofart
        ======
        
        .. image:: https://secure.travis-ci.org/socketubs/sofart.png?branch=master
                :target: https://travis-ci.org/socketubs/sofart
        
        Python in-memory embedded and non-relational database.
        
        For development and test, heavily inspired by `Mongodb <http://www.mongodb.org/>`_.
        
        There are three serializers at this time, ``msgpack``, ``Pickle`` and ``Json`` for storage.
        
        Sofart can be use in-memory synced with ``multi`` mode..
        
        	Sofart is Python 3 ready.
        
        Installation
        ------------
        
        Install with pip: ::
        
        	pip install sofart
        
        Example
        -------
        
        Easy use: ::
        
        	>>> from sofart import Database
        
        Create Database and a collection: ::
        
        	>>> db = Database('/tmp/so.fart')
        	>>> db.create_collection('test_collection')
        	>>> db.collection_names()
        	['test_collection']
        
        Play with collection: ::
        
        	>>> c = db.test_collection
        	>>> post = {"artist": "Jambon",
        	...         "track": "I love my jambon"}
        	>>> c.save(post)
        	>>> for i in c.find_one():
        	...     print(i)
        	...
        	{'track': 'I love my jambon', '_id': 'b2d6bf60-6c11-4e26-9357-efb28056e60d', 'artist': 'Jambon'}
        	>>> c.remove('b2d6bf60-6c11-4e26-9357-efb28056e60d')
        	>>> c.find_one()
        
        Some filter: ::
        
        	>>> c.find_one({"artist": "Jambon"})
        	{'track': 'I love my jambon', '_id': 'b2d6bf60-6c11-4e26-9357-efb28056e60d', 'artist': 'Jambon'}
        	>>> c.find_one({"artist":"Bieber"})
          >>>
        
        Tests
        -----
        
        You can run test under ``tests/test_sofart.py``.
        And there is a populate script into ``tests/populate.py``.
        
        Performances
        ------------
        
        	Single(in-memory) is highly faster than ``multi`` cause it's mainly work in RAM and just down data when sync method is called.
        	In otherwise ``multi`` down data at each request.
        
        But you can have a pretty data control with ``sync`` method which down data in file when you call it.
        
        Serializers
        -----------
        
        ========== === === ====
        Serializer Py2 Py3 Pypy
        ========== === === ====
        Json        1   1   1
        MsgPack     1   1   X
        Pickle      1   1   1
        ========== === === ====
        
        Pypy and ``msgpack-pure`` are not supported.
        
        Misc.
        -----
        
        You can easily write your own serializer, have a look at ``serializers/_msgpack.py`` or ``_json.py`` file.
        
        Remember that if someone write Ruby or other language driver for sofart, maybe using ``json`` or ``msgpack`` could be a good idea.
        
        Docs
        ----
        
        class Database
        ==============
        
        *constructor* ::
        
            Database(str(path), str(mode), str(serializer)) : Path is database file path
                                                            : Mode is single or multi (Default: `single`)
                                                            : Serializer like msgpack, json or pickle (Default: `json`)
        
        *attributs* ::
        
            path: Return database path
        
        *methods* ::
        
            create_collection(str(name))    : Create new collection
            drop_collection(str(name))      : Drop collection
            rename(str(name), str(new_name)): Rename collection `name` to `new_name`
            collection_names(): Return database collections list (same as `collections` attribut)
            count()           : Return total database entries
            sync()            : Save every changes in database file
        
        Retrieve collection with the followings methods:
        
        ::
        
            c = db.my_collection
            c = db['my_collection']
        
        class Collection
        ================
        
        *attributs* ::
        
            name: Return collection name
        
        *methods* ::
        
            drop()           : Drop collection
            count()          : Return total collection entries
            save(dict(enreg)): Save entry into collection
            remove(str(_id)) : Remove entry from collection
            sync()           : Save every changes in database file
            rename(str(name)): Rename collection to `name`
            find_one(spec_or_id)              : Return first founded result
            find(dict(spec_or_id), int(limit)): Iterator which return `limit` result founded (limit=0 return all)
        
        Query
        -----
        
        At this moment just following operands are available:
        
        - ``<``
        - ``<=``
        - ``>``
        - ``>=``
        - ``all``
        - ``exists``
        - ``mod``
        - ``ne``
        - ``in``
        - ``nin``
        
        This is an example: ::
        
        	>>> c.save({"value": 2})
        	>>> c.find({"value": {"$exists": True}})
        	[{'_id': '47e53aea-85b4-434b-8961-40e89c877b41', 'value': 2}]
        	>>> c.find({"value": {"$in": [2, 3, 67]}})
        	[{'_id': '47e53aea-85b4-434b-8961-40e89c877b41', 'value': 2}]
        	>>> c.find({"value" : { "$gt": 1 }})
        	[{'_id': '42567296-7d78-43b7-a4e0-50447b80eca8', 'value': 2}]
        
        And another: ::
        
        	>>> c.find({"value" : { "$gte": 2 }})
        	[{'_id': '42567296-7d78-43b7-a4e0-50447b80eca8', 'value': 2}]
        	>>> c.find({"value" : { "$gte": 2, "$lt" : 1 }})
        	[]
        	>>> c.find({"value": {"$mod": [2, 0]}})
        	[{'_id': '47e53aea-85b4-434b-8961-40e89c877b41', 'value': 2}]
        
        More informations `here <http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries>`_.
        
        See `LICENSE <https://git.socketubs.org/?p=sofart.git;a=blob_plain;f=LICENSE;hb=HEAD>`_.
        
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.0
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
