ohmydata 0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ohmydata-0.2/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
ohmydata-0.2/PKG-INFO ADDED
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.1
2
+ Name: ohmydata
3
+ Version: 0.2
4
+ Summary: An Easy Database Basd On Json
5
+ Project-URL: Home-page, https://github.com/crillerium/
6
+ Author-email: Crillerium <crillerium@outlook.com>
7
+ License-File: LICENSE
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+
14
+ An Easy Database Basd On Json
ohmydata-0.2/README.md ADDED
@@ -0,0 +1 @@
1
+ An Easy Database Basd On Json
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ohmydata"
7
+ version = "0.2"
8
+ authors = [
9
+ { name="Crillerium", email="crillerium@outlook.com" },
10
+ ]
11
+ description = "An Easy Database Basd On Json"
12
+ readme = "README.md"
13
+ requires-python = ">=3.7"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+
20
+ [project.urls]
21
+ "Home-page" = "https://github.com/crillerium/"
File without changes
@@ -0,0 +1,95 @@
1
+ import json
2
+ import os
3
+
4
+ class EasyDB:
5
+ path = ''
6
+ mode = 'buffer' # or 'file'
7
+ data = []
8
+ status = False
9
+ def __init__(self,path=''):
10
+ try:
11
+ if path != '':
12
+ self.path = path
13
+ self.mode = 'file'
14
+ if os.path.isfile(path):
15
+ with open(path) as f:
16
+ content = f.read()
17
+ self.data = json.loads(content) if content != '' else []
18
+ else:
19
+ self.mode = 'buffer'
20
+ self.status = True
21
+ except:
22
+ self.status = False
23
+
24
+ def table(self,tableList:list):
25
+ try:
26
+ if len(self.data) == 0:
27
+ self.data.append(tableList)
28
+ else:
29
+ self.data[0] = tableList
30
+ return True
31
+ except:
32
+ return False
33
+
34
+ def insert(self,record:list):
35
+ try:
36
+ if len(self.data[0]) == len(record):
37
+ self.data.append(record)
38
+ return True
39
+ else:
40
+ return False
41
+ except:
42
+ return False
43
+
44
+
45
+ def fetch_all(self):
46
+ return self.data
47
+
48
+ def fetch(self,call:dict): #call:查询条件
49
+ request = {}
50
+ response = []
51
+ for i in range(0,len(self.data[0])):
52
+ if self.data[0][i] in call.keys():
53
+ request[i] = call[self.data[0][i]]
54
+ total = len(self.data)
55
+ if total == 0:
56
+ return response
57
+ for i in range(0,len(self.data)):
58
+ for key,value in request.items():
59
+ sign = False
60
+ if self.data[i][key] == value:
61
+ sign = True
62
+ if sign:
63
+ response.append(self.data[i])
64
+ return response
65
+
66
+ def delete(self,call):
67
+ try:
68
+ request = {}
69
+ for i in range(0,len(self.data[0])):
70
+ if self.data[0][i] in call.keys():
71
+ request[i] = call[self.data[0][i]]
72
+ total = len(self.data)
73
+ if total == 0:
74
+ return True
75
+ for i in range(0,len(self.data)):
76
+ for key,value in request.items():
77
+ sign = False
78
+ if self.data[i][key] == value:
79
+ sign = True
80
+ if sign:
81
+ self.data.pop(i)
82
+ return True
83
+ except:
84
+ return False
85
+
86
+ def save(self):
87
+ if self.mode == 'file':
88
+ try:
89
+ with open(self.path,'w+') as f:
90
+ f.write(json.dumps(self.data))
91
+ return True
92
+ except:
93
+ return False
94
+ else:
95
+ return False