Skip to content

Commit 1dec0a1

Browse files
committed
feature: update constants in files
1 parent 435eb64 commit 1dec0a1

File tree

3 files changed

+147
-0
lines changed

3 files changed

+147
-0
lines changed

Samples/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Sample implementation
2+
3+
Files:
4+
* `generial`: post, get, count, delete
5+
* `post`: post
6+
7+
1) create virtual environment `virtual ./.venv`
8+
2) activate it ` . ./venv/bin/activate`
9+
3) install dependencies `pip install Rocket-Store`
10+
4) run test `python test.py`

Samples/generic_example.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
"""
2+
█▀ █▄█ █▀▀ █░█ █▀▀ █░█
3+
▄█ ░█░ █▄▄ █▀█ ██▄ ▀▄▀
4+
5+
Author: <Anton Sychev> (anton at sychev dot xyz)
6+
sample.py (c) 2023
7+
Created: 2023-12-01 01:02:01
8+
Desc: sample create instance of RocketStore
9+
Docs: documentation
10+
"""
11+
12+
from Rocketstore import Rocketstore
13+
14+
rs = Rocketstore(**{"data_storage_area": "./test",
15+
"data_format": Rocketstore._FORMAT_JSON})
16+
17+
rs.post("cars", "Mercedes_Benz_GT_R", {"owner": "Lisa Simpson"})
18+
19+
print("GET: ", rs.get("cars", ""), "\n-----\n")
20+
# GET: {'count': 1, 'key': ['Mercedes_Benz_GT_R'], 'result': [{'owner': 'Lisa Simpson'}]}
21+
22+
rs.post("cars", "BMW_740li", {
23+
"owner": "Greg Onslow"}, Rocketstore._ADD_AUTO_INC)
24+
rs.post("cars", "BMW_740li", {"owner": "Sam Wise"}, Rocketstore._ADD_AUTO_INC)
25+
rs.post("cars", "BMW_740li", {"owner": "Bill Bo"}, Rocketstore._ADD_AUTO_INC)
26+
# tienen que haber un BMW_740li
27+
28+
print("GET ALL CARS: ", rs.get("cars", "*"), "\n-----\n")
29+
'''
30+
Get all records:
31+
{
32+
count: 2,
33+
key: [ 'Mercedes_Benz_GT_R', 'BMW_740li' ],
34+
result: [ { owner: 'Lisa Simpson' }, { owner: 'Bill Bo' } ]
35+
}
36+
'''
37+
38+
39+
dataset = {
40+
"Gregs_BMW_740li": {"owner": "Greg Onslow"},
41+
"Lisas_Mercedes_Benz_GT_R": {"owner": "Lisa Simpson"},
42+
"Bills_BMW_740li": {"owner": "Bill Bo"},
43+
}
44+
45+
for i in dataset:
46+
rs.post("cars", i, dataset[i])
47+
48+
print("GET BMW's: ", rs.get("cars", "*BMW*"), "\n-----\n")
49+
'''
50+
Get BMW's:
51+
{
52+
count: 3,
53+
key: [ 'BMW_740li', 'Gregs_BMW_740li', 'Bills_BMW_740li' ],
54+
result: [
55+
{ owner: 'Bill Bo' },
56+
{ owner: 'Greg Onslow' },
57+
{ owner: 'Bill Bo' }
58+
]
59+
}
60+
'''
61+
62+
63+
print("Get list ordered by alphabetically descending keys: ",
64+
rs.get("cars", "", Rocketstore._ORDER_DESC), "\n-----\n")
65+
'''
66+
Get list ordered by alphabetically descending keys:
67+
{
68+
count: 5,
69+
key: [
70+
'Mercedes_Benz_GT_R',
71+
'BMW_740li',
72+
'Gregs_BMW_740li',
73+
'Lisas_Mercedes_Benz_GT_R',
74+
'Bills_BMW_740li'
75+
],
76+
result: [
77+
{ owner: 'Lisa Simpson' },
78+
{ owner: 'Bill Bo' },
79+
{ owner: 'Greg Onslow' },
80+
{ owner: 'Lisa Simpson' },
81+
{ owner: 'Bill Bo' }
82+
]
83+
}
84+
'''
85+
86+
r = rs.delete("cars", "*Mercedes*")
87+
print("Delete all Mercedes's: ", r, "\n-----\n")
88+
''''
89+
Delete all Mercedes's:
90+
{ count: 2 }
91+
92+
'''
93+
94+
print("Return all cars: ", rs.get("cars", "*"), "\n-----\n")
95+
'''
96+
{
97+
count: 3,
98+
key: [ 'BMW_740li', 'Gregs_BMW_740li', 'Bills_BMW_740li' ],
99+
result: [
100+
{ owner: 'Bill Bo' },
101+
{ owner: 'Greg Onslow' },
102+
{ owner: 'Bill Bo' }
103+
]
104+
}
105+
'''
106+
107+
108+
print("Delete all records: ", rs.delete(), "\n-----\n")

Samples/post.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from Rocketstore import Rocketstore
2+
3+
rs = Rocketstore(**{"data_storage_area": "./test"})
4+
5+
print(rs)
6+
print("test Constants:", rs._ADD_AUTO_INC)
7+
print("test Constants: ", Rocketstore._ADD_AUTO_INC)
8+
9+
dataInput = {
10+
"content": "hello asfalsdfsalfaslflasl",
11+
"embeddings": [0.2, 0.31231312, 0.111],
12+
}
13+
14+
15+
out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb",
16+
"memories", dataInput)
17+
18+
print(out)
19+
20+
21+
out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb",
22+
"memories", dataInput, rs._ADD_AUTO_INC)
23+
24+
print(out)
25+
26+
out = rs.post("glOtc6EzYQTZEt0J18cU1f4Ycdz1H8WWTDVkBQTp1Gv2BWgb",
27+
"memories", dataInput, Rocketstore._ADD_AUTO_INC)
28+
29+
print(out)

0 commit comments

Comments
 (0)