From 538bbf801b66c1351470ec348f76e3466fb003ef Mon Sep 17 00:00:00 2001 From: Abdelaziz Elrashed Date: Wed, 11 Dec 2024 09:52:17 +0300 Subject: [PATCH] =?UTF-8?q?=D8=AA=D8=AD=D8=B3=D9=8A=D9=86=20=D8=A7=D9=84?= =?UTF-8?q?=D8=A5=D8=AE=D8=AA=D8=A8=D8=A7=D8=B1=20=D9=84=D9=86=D9=88=D8=B9?= =?UTF-8?q?=20=D8=A7=D9=84=D9=86=D9=85=D9=88=D8=B0=D8=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.ar.md | 16 +++++++++++++--- README.md | 17 ++++++++++++++--- tests/test_00_zakat_tracker.py | 10 +++++++++- zakat/zakat_tracker.py | 27 +++++++++++++++++++++++---- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/README.ar.md b/README.ar.md index de0c5b4..a77da01 100644 --- a/README.ar.md +++ b/README.ar.md @@ -42,6 +42,7 @@ # النموذج نوع قاعدة البيانات + المتطلبات الحالة @@ -50,13 +51,15 @@ + 1 DictModel Camel - جاري العمل عليه + - + مكتمل @@ -70,31 +73,37 @@ SQLModel 1 SQLite - جاري العمل عليه + - + مكتمل 2 MySQL - بالخطة + pymysql + جاري العمل عليه 3 MariaDB + - بالخطة 4 PostgreSQL + - بالخطة 5 CockroachDB + - بالخطة 6 Oracle + - بالخطة @@ -103,6 +112,7 @@ + diff --git a/README.md b/README.md index 01a7d61..05b0180 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Zakat is a user-friendly Python library designed to simplify the tracking and ca # Model Database Engine + Requirements Status @@ -46,13 +47,15 @@ Zakat is a user-friendly Python library designed to simplify the tracking and ca + 1 DictModel Camel - In Progress + - + Done @@ -60,37 +63,44 @@ Zakat is a user-friendly Python library designed to simplify the tracking and ca + 2 SQLModel 1 SQLite - In Progress + - + Done 2 MySQL - Planned + pymysql + In Progress 3 MariaDB + - Planned 4 PostgreSQL + - Planned 5 CockroachDB + - Planned 6 Oracle + - Planned @@ -99,6 +109,7 @@ Zakat is a user-friendly Python library designed to simplify the tracking and ca + diff --git a/tests/test_00_zakat_tracker.py b/tests/test_00_zakat_tracker.py index 1a6cfb6..7cff6bf 100644 --- a/tests/test_00_zakat_tracker.py +++ b/tests/test_00_zakat_tracker.py @@ -2,4 +2,12 @@ def test_zakat_tracker(): - zakat.test(debug=True) + zakat.test( + debug=True, + dict_model=True, + sqlite_model=True, + mysql_model=False, + mariadb_model=False, + postgresql_model=False, + cockroachdb_model=False, + ) diff --git a/zakat/zakat_tracker.py b/zakat/zakat_tracker.py index 37cde51..98693d0 100644 --- a/zakat/zakat_tracker.py +++ b/zakat/zakat_tracker.py @@ -1765,6 +1765,7 @@ def __init__(self, db_path: str = "./zakat_db/zakat.camel"): self._vault = None self.reset() self.path(db_path) + self.provider = 'dict' def path(self, path: str = None) -> str: if path is None: @@ -2704,8 +2705,9 @@ def __init__(self, **db_params): self.debug = False self._file_exists = False self.raw_sql = True + self.provider = str.lower(db_params['provider']) - if str.lower(db_params['provider']) == 'sqlite' and 'filename' in db_params: + if self.provider == 'sqlite' and 'filename' in db_params: db_params['filename'] = str(self.path(db_params['filename'])) self._db_path = db_params['filename'] self._file_exists = True @@ -5045,8 +5047,8 @@ def test( debug: bool = False, dict_model: bool = True, sqlite_model: bool = True, - mariadb_model: bool = False, mysql_model: bool = False, + mariadb_model: bool = False, postgresql_model: bool = False, cockroachdb_model: bool = False, ) -> None: @@ -5062,8 +5064,8 @@ def test( debug: If True, enables detailed logging and output during the test process. dict_model: If True, tests the in-memory dictionary model. sqlite_model: If True, tests the SQLite model. - mariadb_model: If True, tests the MariaDB model. mysql_model: If True, tests the MySQL model. + mariadb_model: If True, tests the MariaDB model. postgresql_model: If True, tests the PostgreSQL model. cockroachdb_model: If True, tests the CockroachDB model. @@ -5095,12 +5097,29 @@ def test( debug=True, ), ) + if mysql_model: + models.append( + SQLModel( + provider='mysql', + host='127.0.0.1', + user='root', + passwd='t00r', + db='zakat', + debug=True, + ), + ) + if mariadb_model: + pass + if postgresql_model: + pass + if cockroachdb_model: + pass for model in models: start = time_ns() assert model.test(debug=debug) ledger = ZakatTracker(model=model) assert ledger.test(debug=debug) - durations[model.__class__.__name__] = time_ns() - start + durations[f'{model.__class__.__name__}({model.provider})'] = time_ns() - start if debug: print("#########################") print("######## TEST DONE ########")