|
| 1 | +Metadata-Version: 2.1 |
| 2 | +Name: Rocket-Store |
| 3 | +Version: 0.0.1 |
| 4 | +Summary: Using the filesystem as a searchable database. |
| 5 | +Author-email: Anton Sychev <anton@sychev.xyz> |
| 6 | +License: Rocket Store |
| 7 | + |
| 8 | + A very simple and yet powerful file storage. |
| 9 | + |
| 10 | + Copyright (c) Paragi 2017, Simon Riget. |
| 11 | + |
| 12 | + Permission is hereby granted, free of charge, to any person obtaining |
| 13 | + a copy of this software and associated documentation files (the |
| 14 | + "Software"), to deal in the Software without restriction, including |
| 15 | + without limitation the rights to use, copy, modify, merge, publish, |
| 16 | + distribute, sublicense, and/or sell copies of the Software, and to |
| 17 | + permit persons to whom the Software is furnished to do so, subject to |
| 18 | + the following conditions: |
| 19 | + |
| 20 | + The above copyright notice and this permission notice shall be |
| 21 | + included in all copies or substantial portions of the Software. |
| 22 | + |
| 23 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 24 | + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 25 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 26 | + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 27 | + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 28 | + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 29 | + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 30 | +Project-URL: Homepage, https://github.com/klich3/rocket-store-python |
| 31 | +Project-URL: Issues, https://github.com/klich3/rocket-store-python/issues |
| 32 | +Keywords: database,store,file,document,database-mangement,record,file-store,store-file,filebase |
| 33 | +Classifier: Programming Language :: Python :: 3 |
| 34 | +Classifier: License :: OSI Approved :: MIT License |
| 35 | +Classifier: Operating System :: OS Independent |
| 36 | +Requires-Python: >=3.8 |
| 37 | +Description-Content-Type: text/markdown |
| 38 | +License-File: LICENSE |
| 39 | +Provides-Extra: build |
| 40 | +Requires-Dist: build; extra == "build" |
| 41 | +Requires-Dist: twine; extra == "build" |
| 42 | + |
| 43 | +# Rocket-Store Python |
| 44 | + |
| 45 | +[](http://opensource.org/licenses/MIT) |
| 46 | +[]( https://github.com/klich3/rocket-store-python/issues ) |
| 47 | +[](https://github.com/klich3/rocket-store-python/pull/) |
| 48 | + |
| 49 | +***Using the filesystem as a searchable database.*** |
| 50 | + |
| 51 | +Rocketstore is a Python library for data storage. It provides an interface for storing and retrieving data in various formats. |
| 52 | + |
| 53 | +***ORIGINAL / NODE VERSION:*** https://github.com/Paragi/rocket-store/ |
| 54 | + |
| 55 | +You can download from PyPi repository: https://pypi.org/project/Rocket-Store/ |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +# Basic terminology |
| 60 | + |
| 61 | +Rocket-Store was made to replace a more complex database, in a setting that required a low footprint and high performance. |
| 62 | + |
| 63 | +Rocket-Store is intended to store and retrieve records/documents, organized in collections, using a key. |
| 64 | + |
| 65 | +Terms used: |
| 66 | +* __Collection__: name of a collections of records. (Like an SQL table) |
| 67 | +* __Record__: the data store. (Like an SQL row) |
| 68 | +* __Data storage area__: area/directory where collections are stored. (Like SQL data base) |
| 69 | +* __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. |
| 70 | + |
| 71 | +Compare Rocket-Store, SQL and file system terms: |
| 72 | + |
| 73 | +| Rocket-Store | SQL| File system | |
| 74 | +|---|---|--- |
| 75 | +| __storage area__ | database | data directory root | |
| 76 | +| __collection__ | table | directory | |
| 77 | +| __key__ | key | file name | |
| 78 | +| __record__ | row | file | |
| 79 | + |
| 80 | + |
| 81 | +## Features |
| 82 | + |
| 83 | +- Support for file locking. |
| 84 | +- Support for creating data storage directories. |
| 85 | +- Support for adding auto incrementing sequences and GUIDs to keys. |
| 86 | + |
| 87 | + |
| 88 | +## Usage |
| 89 | + |
| 90 | +To use Rocketstore, you must first import the library: |
| 91 | + |
| 92 | +```python |
| 93 | +from Rocketstore import Rocketstore, _FORMAT_JSON |
| 94 | +``` |
| 95 | + |
| 96 | +### Post |
| 97 | + |
| 98 | +```python |
| 99 | +rs.post(collection="delete_fodders1", key="1", record={"some":"json input"}, flags=_FORMAT_JSON) |
| 100 | +# or |
| 101 | +rs.post("delete_fodders1", "1", {"some":"json input"}, _FORMAT_JSON) |
| 102 | +``` |
| 103 | + |
| 104 | +Stores a record in a collection identified by a unique key |
| 105 | + |
| 106 | +__Collection__ name to contain the records. |
| 107 | + |
| 108 | +__Key__ uniquely identifying the record |
| 109 | + |
| 110 | +No path separators or wildcards etc. are allowed in collection names and keys. |
| 111 | +Illigal charakters are silently striped off. |
| 112 | + |
| 113 | +__Content__ Data input to store |
| 114 | + |
| 115 | +__Options__ |
| 116 | + * _ADD_AUTO_INC: Add an auto incremented sequence to the beginning of the key |
| 117 | + * _ADD_GUID: Add a Globally Unique IDentifier to the key |
| 118 | + |
| 119 | +__Returns__ an associative array containing the result of the operation: |
| 120 | +* count : number of records affected (1 on succes) |
| 121 | +* key: string containing the actual key used |
| 122 | + |
| 123 | + |
| 124 | +If the key already exists, the record will be replaced. |
| 125 | + |
| 126 | +If no key is given, an auto-incremented sequence is used as key. |
| 127 | + |
| 128 | +If the function fails for any reason, an error is thrown. |
| 129 | + |
| 130 | +### Get |
| 131 | + |
| 132 | +Find and retrieve records, in a collection. |
| 133 | + |
| 134 | +```python |
| 135 | +rs.get(collection="delete_fodders1") |
| 136 | +# or |
| 137 | +rs.get("delete_fodders1") |
| 138 | +# Get wildcar |
| 139 | +rs.get("delete_*") |
| 140 | +``` |
| 141 | + |
| 142 | +__Collection__ to search. If no collection name is given, get will return a list of data base assets: collections and sequences etc. |
| 143 | + |
| 144 | +__Key__ to search for. Can be mixed with wildcards '\*' and '?'. An undefined or empty key is the equivalent of '*' |
| 145 | + |
| 146 | +__Options__: |
| 147 | + * _ORDER : Results returned are ordered alphabetically ascending. |
| 148 | + * _ORDER_DESC : Results returned are ordered alphabetically descending. |
| 149 | + * _KEYS : Return keys only (no records) |
| 150 | + * _COUNT : Return record count only |
| 151 | + |
| 152 | +__Return__ an array of |
| 153 | +* count : number of records affected |
| 154 | +* key : array of keys |
| 155 | +* result : array of records |
| 156 | + |
| 157 | +NB: wildcards are very expensive on large datasets with most filesystems. |
| 158 | +(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) |
| 159 | + |
| 160 | +### Delete |
| 161 | + |
| 162 | +Delete one or more records, whos key match. |
| 163 | + |
| 164 | +```python |
| 165 | +# Delete database |
| 166 | +rs.delete() |
| 167 | + |
| 168 | +# Delete collection with content |
| 169 | +rs.delete("delete_fodders1") |
| 170 | + |
| 171 | +# Delete wild collection |
| 172 | +rs.delete("delete_*") |
| 173 | + |
| 174 | +# Delete exact key |
| 175 | +rs.delete("delete_fodders1", "1") |
| 176 | + |
| 177 | +``` |
| 178 | + |
| 179 | +__Collection__ to search. If no collection is given, **THE WHOLE DATA BASE IS DELETED!** |
| 180 | + |
| 181 | +__Key__ to search for. Can be mixed with wildcards '\*' and '?'. If no key is given, **THE ENTIRE COLLECTION INCLUDING SEQUENCES IS DELETED!** |
| 182 | + |
| 183 | +__Return__ an array of |
| 184 | +* count : number of records or collections affected |
| 185 | + |
| 186 | +### Options |
| 187 | + |
| 188 | +Can be called at any time to change the configuration values of the initialized instance |
| 189 | + |
| 190 | +__Options__: |
| 191 | + * 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. |
| 192 | + * data_format: Specify which format the records are stored in. Values are: _FORMAT_NATIVE - default. and RS_FORMAT_JSON - Use JSON data format. |
| 193 | + |
| 194 | +```python |
| 195 | +rs.options(data_format=_FORMAT_JSON) |
| 196 | +# or |
| 197 | +rs.options(**{ |
| 198 | + "data_format": _FORMAT_JSON, |
| 199 | + ... |
| 200 | +}) |
| 201 | +``` |
| 202 | + |
| 203 | +#### Inserting with Globally Unique IDentifier key |
| 204 | + |
| 205 | +Another option is to add a GUID to the key. |
| 206 | +The GUID is a combination of a timestamp and a random sequence, formatet in accordance to RFC 4122 (Valid but slightly less random) |
| 207 | + |
| 208 | +If ID's are generated more than 1 millisecond apart, they are 100% unique. |
| 209 | +If two ID's are generated at shorter intervals, the likelyhod of collission is up to 1 of 10^15. |
| 210 | + |
| 211 | +--- |
| 212 | + |
| 213 | +### Contribute |
| 214 | +Contributions are welcome. Please open an issue to discuss what you would like to change. |
| 215 | + |
| 216 | +--- |
| 217 | + |
| 218 | +### Docs: |
| 219 | +* https://packaging.python.org/en/latest/tutorials/packaging-projects/ |
| 220 | +* https://realpython.com/pypi-publish-python-package/ |
| 221 | + |
| 222 | +### Publish to Pypi |
| 223 | + |
| 224 | +```shell |
| 225 | +python -m pip install build twine |
| 226 | +python3 -m build |
| 227 | +twine check dist/* |
| 228 | +twine upload dist/* |
| 229 | +``` |
0 commit comments