Data storage made simple
Project description
Arowana
Arowana provides a simple local base and drive. Base is a NoSQL wrapper for sqlite3 and drive is a wrapper for the filesystem. Arowana is a sister project of fishweb.
Installation
pip install arowana
Base
Base is a simple NoSQL wrapper for sqlite3. To get started define the location and name of the base.
from arowana import Arowana
arowana = Arowana("data") # Creates 'data' folder
base = arowana.Base("testing") # Creates base/table 'testing'
put
Put item into base. Overrides existing item if key already exists
Args:
- data: The data to be stored
- key: The key to store the data under. If None, a new key will be generated
Returns:
- dict: Added item details
# Key is automatically generated
# Returns: {"name": "sofa", "price": 20, "key": "generated_key"}
base.put({"name": "sofa", "price": 20})
# Set key as "one"
# Returns: {"name": "sofa", "price": 20, "key": "one"}
base.put({"name": "sofa", "price": 20}, "one")
# The key can also be included in the object
# Returns: {"name": "sofa", "price": 20, "key": "test"}
base.put({"name": "sofa", "price": 20, "key": "test"})
# Supports multiple types
# Returns: {"key": "generated_key", "value": "hello, worlds"}
base.put("hello, worlds")
# Returns: {"key": "generated_key", "value": 7}
base.put(7)
# Returns: {"key": "generated_key", "value": true}
base.put(True)
# Returns: {"key": "name", "value": "sofa"}
base.put(data="sofa", key="name")
puts
Put multiple items into base
Args:
- items: Items to add
Returns:
- dict: Added items details
# Returns: {"items": [
# {"name": "sofa", "hometown": "Sofa islands", "key": "slumberdemon"},
# {"key": "generated_key", "value": ["nemo", "arowana", "fishweb", "clownfish"]},
# {"key": "generated_key", "value": "goldfish"}
# ]}
base.puts(
[
{"name": "sofa", "hometown": "Sofa islands", "key": "slumberdemon"}, # Key provided.
["nemo", "arowana", "fishweb", "clownfish"], # Key auto-generated.
"goldfish", # Key auto-generated.
],
)
insert
Insert item to base. Does not override existing item if key already exists
Args:
- data: The data to be stored
- key: The key to store the data under. If None, a new key will be generated
Returns:
- dict: Added item details
# Will succeed and auto generate a key
# Returns: {"key": "generated_key", "value": "hello, world"}
base.insert("hello, world")
# Will succeed with key "greeting1"
# Returns: {"message": "hello, world", "key": "greeting1"}
base.insert({"message": "hello, world"}, "greeting1")
# Will raise an error as key "greeting1" already exists
base.insert({"message": "hello, there"}, "greeting1")
get
Get item from base.
Args:
- key: key of the item to retrieve
Returns:
- dict: Retrieved item details
# If the stored item is a dictionary, returns the dict with a "key" field:
# {"name": "sofa", "price": 20, "key": "one"}
base.get("one")
# If the stored item is a non-dict value, returns:
# {"key": "my_key", "value": "stored_value"}
base.get("my_key")
delete
Delete item from base.
Args:
- key: key of the item to delete
base.delete("sofa")
update
Update item in base
Args:
- data: Attributes to update
- key: Key of the item to update
base.update(
{
"name": "sofa", # Set name to "sofa"
"status.active": True, # Set "status.active" to True
"description": base.util.trim(), # Remove description element
"likes": base.util.append("fishing"), # Append fishing to likes array
"age": base.util.increment(1), # Increment age by 1
},
"slumberdemon",
)
all
Get all items in base
Returns:
- dict: All items
# Returns: {"items": [
# {"name": "sofa", "price": 20, "key": "one"},
# {"key": "my_string", "value": "hello world"},
# ...
# ]}
base.all()
drop
Delete base from database
base.drop()
utils
util.trim()- Remove element from dictutil.increment(value)- Increment element by valueutil.subtract(value)- Subtract element by valueutil.append(value)- Append element to list
Drive
Drive makes it super easy to store and manage files.
from arowana import Arowana
arowana = Arowana("data") # Creates 'data' folder
drive = arowana.Drive("testing") # Creates folder/drive 'testing'
put
Put file
Args:
- name: Name and path of the file
- data: Data content of file
- path: Path of file to get content from
Returns:
- str: Name of the file
# Put content directly
drive.put("hello.txt", "Hello world")
drive.put(b"hello.txt", "Hello world")
import io
# Provide file content object
drive.put("arowana.txt", io.StringIO("hello world"))
drive.put("arowana.txt", io.BytesIO(b"hello world"))
with open("./arowana.txt", "r") as file:
drive.put("arowana.txt", file)
# Provide a path to a file.
drive.put("arowana.txt", path="./arowana.txt")
get
Get file content
Args:
- name: Name and path of the file
Returns:
- bytes: File bytes
drive.get("arowana.txt")
list
List all files
Args:
- prefix: Prefix that file names start with
Returns:
- list: List of file names
drive.list()
delete
Delete file
Args:
- name: Name and path of the file
Returns:
- str: Name of the deleted file
drive.delete("arowana.txt")
Fishweb
To learn more about using arowana with fishweb read the documentation.
Inspirations
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arowana-0.1.6.tar.gz.
File metadata
- Download URL: arowana-0.1.6.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcbf1f6f18d4008850d8acb11202b05d525219e905f0a011cc5f2b6095ca96d5
|
|
| MD5 |
0db6816f26ba7b65eba691adbe1ab158
|
|
| BLAKE2b-256 |
57959a726310a12534688f5c68f0ee120ec2fc50833fbf57c64f498b5c9e4677
|
Provenance
The following attestation bundles were made for arowana-0.1.6.tar.gz:
Publisher:
release.yml on SlumberDemon/arowana
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arowana-0.1.6.tar.gz -
Subject digest:
fcbf1f6f18d4008850d8acb11202b05d525219e905f0a011cc5f2b6095ca96d5 - Sigstore transparency entry: 975751332
- Sigstore integration time:
-
Permalink:
SlumberDemon/arowana@7286ccbdc72093256fa773e412b18253c4439f91 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/SlumberDemon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7286ccbdc72093256fa773e412b18253c4439f91 -
Trigger Event:
push
-
Statement type:
File details
Details for the file arowana-0.1.6-py3-none-any.whl.
File metadata
- Download URL: arowana-0.1.6-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c3fa89781498f22df950ffa64f60c49a31382ea6858fd6e6c4ec1e27b8c37b3
|
|
| MD5 |
55367b930f9c26d4ab6830391e781b5b
|
|
| BLAKE2b-256 |
282afc476fda593e7907d02c73692ba5e6cc03c7b65fc8aa033f6a2e29e51f7f
|
Provenance
The following attestation bundles were made for arowana-0.1.6-py3-none-any.whl:
Publisher:
release.yml on SlumberDemon/arowana
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arowana-0.1.6-py3-none-any.whl -
Subject digest:
7c3fa89781498f22df950ffa64f60c49a31382ea6858fd6e6c4ec1e27b8c37b3 - Sigstore transparency entry: 975751363
- Sigstore integration time:
-
Permalink:
SlumberDemon/arowana@7286ccbdc72093256fa773e412b18253c4439f91 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/SlumberDemon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7286ccbdc72093256fa773e412b18253c4439f91 -
Trigger Event:
push
-
Statement type: