Skip to content

Commit a957191

Browse files
committed
Created Simple Database system
1 parent 65eee83 commit a957191

File tree

6 files changed

+90
-0
lines changed

6 files changed

+90
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
#Manual
2+
3+
4+
5+
16
# Byte-compiled / optimized / DLL files
27
__pycache__/
8+
.idea
9+
.vscode
310
*.py[cod]
411
*$py.class
512

filexdb/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .database import FileXdb
2+
# from .collection import Collection
3+
# from .document import Document

filexdb/collection.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from .document import Document
2+
import json
3+
4+
5+
class Collection:
6+
def __init__(self, database, db_name, col_name: str) -> None:
7+
self._database = database
8+
self._db_name = db_name
9+
self._col_name = col_name
10+
11+
self._database[self._col_name] = []
12+
# self._collection = list(self._database[self._col_name])
13+
14+
def insert(self, doc: dict) -> None:
15+
_doc = doc
16+
print(_doc)
17+
print(self._database)
18+
# data = list(self._collection).append(doc)
19+
data = self._database[self._col_name].append(_doc)
20+
print(self._database)
21+
with open(f"{self._db_name}.json", "w") as f:
22+
json.dump(self._database, f, indent=4)
23+

filexdb/database.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import Dict, Type, List
2+
3+
from .collection import Collection
4+
5+
6+
class FileXdb:
7+
8+
def __init__(self, db_name):
9+
self.database = {}
10+
self.db_name = db_name
11+
12+
def collection(self, col_name) -> Collection:
13+
collection = Collection(self.database, self.db_name, col_name)
14+
# self.database[col_name] = collection
15+
16+
return collection
17+
18+
def show_collections(self):
19+
pass

filexdb/document.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
class Document(dict):
4+
def __init__(self) -> None:
5+
super().__init__()

setup.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from setuptools import setup, find_packages
2+
import codecs
3+
import os
4+
5+
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
6+
VERSION = '1.0.0'
7+
DESCRIPTION = r"A File Based, Local, Simple, NoSQL DataBase"
8+
9+
with codecs.open(os.path.join(BASE_DIR, "README.md"), encoding="utf-8") as fh:
10+
long_description = "\n" + fh.read()
11+
12+
# Setting up
13+
setup(
14+
name="filexdb",
15+
version=VERSION,
16+
author="Sam (AcePic Studio)",
17+
author_email="sam@acepicstudio.com",
18+
description=DESCRIPTION,
19+
long_description_content_type="text/markdown",
20+
long_description=long_description,
21+
packages=find_packages(),
22+
install_requires=[],
23+
keywords=['python', 'dev-tool', 'database', 'local database'],
24+
classifiers=[
25+
"Development Status :: 1 - Planning",
26+
"Intended Audience :: Developers",
27+
"Programming Language :: Python :: 3",
28+
"Operating System :: Unix",
29+
"Operating System :: MacOS :: MacOS X",
30+
"Operating System :: Microsoft :: Windows",
31+
]
32+
33+
)

0 commit comments

Comments
 (0)