Rocket-Store


NameRocket-Store JSON
Version 0.0.10 PyPI version JSON
download
home_page
SummaryUsing the filesystem as a searchable database.
upload_time2024-01-11 11:39:34
maintainer
docs_urlNone
author
requires_python>=3.8
licenseRocket Store A very simple and yet powerful file storage. Copyright (c) Paragi 2017, Simon Riget. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords database store file document database-mangement record file-store store-file filebase
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Rocket-Store Python

[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
[![Issues](http://img.shields.io/github/issues/klich3/rocket-store-python.svg)]( https://github.com/klich3/rocket-store-python/issues )
[![GitHub pull-requests](https://img.shields.io/github/issues-pr/paragi/rocket-store.svg)](https://github.com/klich3/rocket-store-python/pull/)

***Using the filesystem as a searchable database.***

Rocketstore is a Python library for data storage. It provides an interface for storing and retrieving data in various formats.

***ORIGINAL / NODE VERSION:*** https://github.com/Paragi/rocket-store/

You can download from PyPi repository: https://pypi.org/project/Rocket-Store/

---

# Basic terminology

Rocket-Store was made to replace a more complex database, in a setting that required a low footprint and high performance.

Rocket-Store is intended to store and retrieve records/documents, organized in collections, using a key.

Terms used:
* __Collection__: name of a collections of records. (Like an SQL table)
* __Record__: the data store. (Like an SQL row)
* __Data storage area__: area/directory where collections are stored. (Like SQL data base)
* __Key__: every record has exactly one unique key, which is the same as a file name (same restrictions) and the same wildcards used in searches.

Compare Rocket-Store, SQL and file system terms:

| Rocket-Store | SQL| File system |
|---|---|---
| __storage area__     |  database     |  data directory root   |
| __collection__       |  table        |  directory             |
| __key__              |  key          |  file name             |
| __record__           |  row          |  file                  |


## Features

- Support for file locking.
- Support for creating data storage directories.
- Support for adding auto incrementing sequences and GUIDs to keys.


## Usage

To use Rocketstore, you must first import the library:

```python
from Rocketstore import Rocketstore

rs = Rocketstore()
```

usage of constants:
```python

#method 1:
rs = Rocketstore()
rs.post(..., rs._FORMAT_JSON)

#or 

rs.post(..., Rocketstore._FORMAT_JSON)

```


### Post

```python
rs.post(collection="delete_fodders1", key="1", record={"some":"json input"}, flags=Rocketstore._FORMAT_JSON)
# or
rs.post("delete_fodders1", "1", {"some":"json input"}, Rocketstore._FORMAT_JSON)
```

Stores a record in a collection identified by a unique key

__Collection__ name to contain the records.

__Key__ uniquely identifying the record

No path separators or wildcards etc. are allowed in collection names and keys.
Illigal charakters are silently striped off.

__Content__ Data input to store

__Options__
  * _ADD_AUTO_INC:  Add an auto incremented sequence to the beginning of the key
  * _ADD_GUID: Add a Globally Unique IDentifier to the key

__Returns__ an associative array containing the result of the operation:
* count : number of records affected (1 on succes)
* key:   string containing the actual key used


If the key already exists, the record will be replaced.

If no key is given, an auto-incremented sequence is used as key.

If the function fails for any reason, an error is thrown.

### Get

Find and retrieve records, in a collection.

```python
rs.get(collection="delete_fodders1")
# or
rs.get("delete_fodders1")
# Get wildcar
rs.get("delete_*")
```

__Collection__ to search. If no collection name is given, get will return a list of data base assets: collections and sequences etc.

__Key__ to search for. Can be mixed with wildcards '\*' and '?'. An undefined or empty key is the equivalent of '*'

__Options__:
  * _ORDER       : Results returned are ordered alphabetically ascending.
  * _ORDER_DESC  : Results returned are ordered alphabetically descending.
  * _KEYS        : Return keys only (no records)
  * _COUNT       : Return record count only

__Return__ an array of
* count   : number of records affected
* key     : array of keys
* result  : array of records

NB: wildcards are very expensive on large datasets with most filesystems.
(on a regular PC with +10^7 records in the collection, it might take up to a second to retreive one record, whereas one might retrieve up to 100.000 records with an exact key match)

### Delete

Delete one or more records, whos key match.

```python
# Delete database
rs.delete()

# Delete collection with content
rs.delete("delete_fodders1")

# Delete wild collection 
rs.delete("delete_*")

# Delete exact key
rs.delete("delete_fodders1", "1")

```

__Collection__ to search. If no collection is given, **THE WHOLE DATA BASE IS DELETED!**

__Key__ to search for. Can be mixed with wildcards '\*' and '?'. If no key is given, **THE ENTIRE COLLECTION INCLUDING SEQUENCES IS DELETED!**

__Return__ an array of
* count : number of records or collections affected

### Options

Can be called at any time to change the configuration values of the initialized instance

__Options__:
  * data_storage_area: The directory where the database resides. The default is to use a subdirectory to the temporary directory provided by the operating system. If that doesn't work, the DOCUMENT_ROOT directory is used.
  * data_format: Specify which format the records are stored in. Values are: _FORMAT_NATIVE - default. and RS_FORMAT_JSON - Use JSON data format.

```python
rs.options(data_format=Rocketstore._FORMAT_JSON)
# or
rs.options(**{
  "data_format": Rocketstore._FORMAT_JSON,
  ...
})
```

#### Inserting with Globally Unique IDentifier key

Another option is to add a GUID to the key.
The GUID is a combination of a timestamp and a random sequence, formatet in accordance to  RFC 4122 (Valid but slightly less random)

If ID's are generated more than 1 millisecond apart, they are 100% unique.
If two ID's are generated at shorter intervals, the likelyhod of collission is up to 1 of 10^15.

---

### Contribute
Contributions are welcome. Please open an issue to discuss what you would like to change.

---

### Docs:
* https://packaging.python.org/en/latest/tutorials/packaging-projects/
* https://realpython.com/pypi-publish-python-package/

### Publish to Pypi

***Local:***
```shell
python -m pip install build twine
python3 -m build   
twine check dist/*
twine upload dist/*
```

***Live:***
No need do nothing GitHub have Workflow action its publish auto

----

### Local dev

In root folder run create virtual env `virtualenv ./venv && . ./venv/bin/activate`
and run `pip install -e .`

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "Rocket-Store",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "database,store,file,document,database-mangement,record,file-store,store-file,filebase",
    "author": "",
    "author_email": "Anton Sychev <anton@sychev.xyz>",
    "download_url": "https://files.pythonhosted.org/packages/bb/b5/16e9ddb06b600a425da0a2bfcc2f9cda5e7ed55c1cb0340e8689db185c00/Rocket-Store-0.0.10.tar.gz",
    "platform": null,
    "description": "# Rocket-Store Python\n\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n[![Issues](http://img.shields.io/github/issues/klich3/rocket-store-python.svg)]( https://github.com/klich3/rocket-store-python/issues )\n[![GitHub pull-requests](https://img.shields.io/github/issues-pr/paragi/rocket-store.svg)](https://github.com/klich3/rocket-store-python/pull/)\n\n***Using the filesystem as a searchable database.***\n\nRocketstore is a Python library for data storage. It provides an interface for storing and retrieving data in various formats.\n\n***ORIGINAL / NODE VERSION:*** https://github.com/Paragi/rocket-store/\n\nYou can download from PyPi repository: https://pypi.org/project/Rocket-Store/\n\n---\n\n# Basic terminology\n\nRocket-Store was made to replace a more complex database, in a setting that required a low footprint and high performance.\n\nRocket-Store is intended to store and retrieve records/documents, organized in collections, using a key.\n\nTerms used:\n* __Collection__: name of a collections of records. (Like an SQL table)\n* __Record__: the data store. (Like an SQL row)\n* __Data storage area__: area/directory where collections are stored. (Like SQL data base)\n* __Key__: every record has exactly one unique key, which is the same as a file name (same restrictions) and the same wildcards used in searches.\n\nCompare Rocket-Store, SQL and file system terms:\n\n| Rocket-Store | SQL| File system |\n|---|---|---\n| __storage area__     |  database     |  data directory root   |\n| __collection__       |  table        |  directory             |\n| __key__              |  key          |  file name             |\n| __record__           |  row          |  file                  |\n\n\n## Features\n\n- Support for file locking.\n- Support for creating data storage directories.\n- Support for adding auto incrementing sequences and GUIDs to keys.\n\n\n## Usage\n\nTo use Rocketstore, you must first import the library:\n\n```python\nfrom Rocketstore import Rocketstore\n\nrs = Rocketstore()\n```\n\nusage of constants:\n```python\n\n#method 1:\nrs = Rocketstore()\nrs.post(..., rs._FORMAT_JSON)\n\n#or \n\nrs.post(..., Rocketstore._FORMAT_JSON)\n\n```\n\n\n### Post\n\n```python\nrs.post(collection=\"delete_fodders1\", key=\"1\", record={\"some\":\"json input\"}, flags=Rocketstore._FORMAT_JSON)\n# or\nrs.post(\"delete_fodders1\", \"1\", {\"some\":\"json input\"}, Rocketstore._FORMAT_JSON)\n```\n\nStores a record in a collection identified by a unique key\n\n__Collection__ name to contain the records.\n\n__Key__ uniquely identifying the record\n\nNo path separators or wildcards etc. are allowed in collection names and keys.\nIlligal charakters are silently striped off.\n\n__Content__ Data input to store\n\n__Options__\n  * _ADD_AUTO_INC:  Add an auto incremented sequence to the beginning of the key\n  * _ADD_GUID: Add a Globally Unique IDentifier to the key\n\n__Returns__ an associative array containing the result of the operation:\n* count : number of records affected (1 on succes)\n* key:   string containing the actual key used\n\n\nIf the key already exists, the record will be replaced.\n\nIf no key is given, an auto-incremented sequence is used as key.\n\nIf the function fails for any reason, an error is thrown.\n\n### Get\n\nFind and retrieve records, in a collection.\n\n```python\nrs.get(collection=\"delete_fodders1\")\n# or\nrs.get(\"delete_fodders1\")\n# Get wildcar\nrs.get(\"delete_*\")\n```\n\n__Collection__ to search. If no collection name is given, get will return a list of data base assets: collections and sequences etc.\n\n__Key__ to search for. Can be mixed with wildcards '\\*' and '?'. An undefined or empty key is the equivalent of '*'\n\n__Options__:\n  * _ORDER       : Results returned are ordered alphabetically ascending.\n  * _ORDER_DESC  : Results returned are ordered alphabetically descending.\n  * _KEYS        : Return keys only (no records)\n  * _COUNT       : Return record count only\n\n__Return__ an array of\n* count   : number of records affected\n* key     : array of keys\n* result  : array of records\n\nNB: wildcards are very expensive on large datasets with most filesystems.\n(on a regular PC with +10^7 records in the collection, it might take up to a second to retreive one record, whereas one might retrieve up to 100.000 records with an exact key match)\n\n### Delete\n\nDelete one or more records, whos key match.\n\n```python\n# Delete database\nrs.delete()\n\n# Delete collection with content\nrs.delete(\"delete_fodders1\")\n\n# Delete wild collection \nrs.delete(\"delete_*\")\n\n# Delete exact key\nrs.delete(\"delete_fodders1\", \"1\")\n\n```\n\n__Collection__ to search. If no collection is given, **THE WHOLE DATA BASE IS DELETED!**\n\n__Key__ to search for. Can be mixed with wildcards '\\*' and '?'. If no key is given, **THE ENTIRE COLLECTION INCLUDING SEQUENCES IS DELETED!**\n\n__Return__ an array of\n* count : number of records or collections affected\n\n### Options\n\nCan be called at any time to change the configuration values of the initialized instance\n\n__Options__:\n  * data_storage_area: The directory where the database resides. The default is to use a subdirectory to the temporary directory provided by the operating system. If that doesn't work, the DOCUMENT_ROOT directory is used.\n  * data_format: Specify which format the records are stored in. Values are: _FORMAT_NATIVE - default. and RS_FORMAT_JSON - Use JSON data format.\n\n```python\nrs.options(data_format=Rocketstore._FORMAT_JSON)\n# or\nrs.options(**{\n  \"data_format\": Rocketstore._FORMAT_JSON,\n  ...\n})\n```\n\n#### Inserting with Globally Unique IDentifier key\n\nAnother option is to add a GUID to the key.\nThe GUID is a combination of a timestamp and a random sequence, formatet in accordance to  RFC 4122 (Valid but slightly less random)\n\nIf ID's are generated more than 1 millisecond apart, they are 100% unique.\nIf two ID's are generated at shorter intervals, the likelyhod of collission is up to 1 of 10^15.\n\n---\n\n### Contribute\nContributions are welcome. Please open an issue to discuss what you would like to change.\n\n---\n\n### Docs:\n* https://packaging.python.org/en/latest/tutorials/packaging-projects/\n* https://realpython.com/pypi-publish-python-package/\n\n### Publish to Pypi\n\n***Local:***\n```shell\npython -m pip install build twine\npython3 -m build   \ntwine check dist/*\ntwine upload dist/*\n```\n\n***Live:***\nNo need do nothing GitHub have Workflow action its publish auto\n\n----\n\n### Local dev\n\nIn root folder run create virtual env `virtualenv ./venv && . ./venv/bin/activate`\nand run `pip install -e .`\n",
    "bugtrack_url": null,
    "license": "Rocket Store  A very simple and yet powerful file storage.  Copyright (c) Paragi 2017, Simon Riget.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Using the filesystem as a searchable database.",
    "version": "0.0.10",
    "project_urls": {
        "Homepage": "https://github.com/klich3/rocket-store-python",
        "Issues": "https://github.com/klich3/rocket-store-python/issues"
    },
    "split_keywords": [
        "database",
        "store",
        "file",
        "document",
        "database-mangement",
        "record",
        "file-store",
        "store-file",
        "filebase"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e7ee2633259fd5a539ef80de5d878ef671b4d8f5e2fa14336437bb24b0e3788",
                "md5": "9879924950bab8223243150c6cbdcac3",
                "sha256": "37b01c2fa7de411c5d84de5039bad3e7d49652cef6d5facb557348c5e55038f5"
            },
            "downloads": -1,
            "filename": "Rocket_Store-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9879924950bab8223243150c6cbdcac3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12951,
            "upload_time": "2024-01-11T11:39:32",
            "upload_time_iso_8601": "2024-01-11T11:39:32.908162Z",
            "url": "https://files.pythonhosted.org/packages/5e/7e/e2633259fd5a539ef80de5d878ef671b4d8f5e2fa14336437bb24b0e3788/Rocket_Store-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bbb516e9ddb06b600a425da0a2bfcc2f9cda5e7ed55c1cb0340e8689db185c00",
                "md5": "97cf5a8c2de0ca82062ca202ac22ddb4",
                "sha256": "aa99da022babe8a1e23b9e6e128a425afe7845ec80611a7a620cfa7b3b7888e2"
            },
            "downloads": -1,
            "filename": "Rocket-Store-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "97cf5a8c2de0ca82062ca202ac22ddb4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13676,
            "upload_time": "2024-01-11T11:39:34",
            "upload_time_iso_8601": "2024-01-11T11:39:34.428830Z",
            "url": "https://files.pythonhosted.org/packages/bb/b5/16e9ddb06b600a425da0a2bfcc2f9cda5e7ed55c1cb0340e8689db185c00/Rocket-Store-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-11 11:39:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "klich3",
    "github_project": "rocket-store-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "rocket-store"
}
        
Elapsed time: 0.16973s