Skip to content

Commit 41cbbd1

Browse files
committed
Modified db name & dir
1 parent 6d978ed commit 41cbbd1

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

filexdb/database.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@
55

66
class FileXdb:
77

8-
def __init__(self, db_name):
9-
self.database = {}
10-
self.db_name = db_name
8+
def __init__(self, db_name: str, data_dir: str | None):
9+
"""
10+
Creates a Databased in ``data_dir`` Directory named ``db_name``.
1111
12-
def collection(self, col_name) -> Collection:
13-
collection = Collection(self.database, self.db_name, col_name)
12+
If Database is already exists, interacts with that.
13+
14+
[Recommended]
15+
Don't add any file extension. ``FileXdb`` will create its own file extension ``fxdb``.
16+
17+
:param db_name: Name of Database without file extension.
18+
:param data_dir: Where the Database will be stored.
19+
"""
20+
21+
self._database = {}
22+
self._db_name = db_name
23+
self._data_dir = data_dir
24+
25+
def collection(self, col_name: str) -> Collection:
26+
collection = Collection(self._database, self._db_name, col_name)
1427
# self.database[col_name] = collection
1528

1629
return collection

0 commit comments

Comments
 (0)