pam-python 0.1.18__tar.gz → 0.1.20__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.
Files changed (36) hide show
  1. {pam_python-0.1.18/pam_python.egg-info → pam_python-0.1.20}/PKG-INFO +1 -1
  2. {pam_python-0.1.18 → pam_python-0.1.20}/pam/service.py +2 -2
  3. pam_python-0.1.20/pam/sqlite.py +75 -0
  4. {pam_python-0.1.18 → pam_python-0.1.20/pam_python.egg-info}/PKG-INFO +1 -1
  5. {pam_python-0.1.18 → pam_python-0.1.20}/pam_python.egg-info/SOURCES.txt +1 -0
  6. {pam_python-0.1.18 → pam_python-0.1.20}/setup.py +1 -1
  7. {pam_python-0.1.18 → pam_python-0.1.20}/LICENSE.txt +0 -0
  8. {pam_python-0.1.18 → pam_python-0.1.20}/README.md +0 -0
  9. {pam_python-0.1.18 → pam_python-0.1.20}/pam/__init__.py +0 -0
  10. {pam_python-0.1.18 → pam_python-0.1.20}/pam/api.py +0 -0
  11. {pam_python-0.1.18 → pam_python-0.1.20}/pam/cli.py +0 -0
  12. {pam_python-0.1.18 → pam_python-0.1.20}/pam/interface_task_manager.py +0 -0
  13. {pam_python-0.1.18 → pam_python-0.1.20}/pam/models/__init__.py +0 -0
  14. {pam_python-0.1.18 → pam_python-0.1.20}/pam/models/request_command.py +0 -0
  15. {pam_python-0.1.18 → pam_python-0.1.20}/pam/server.py +0 -0
  16. {pam_python-0.1.18 → pam_python-0.1.20}/pam/task_manager.py +0 -0
  17. {pam_python-0.1.18 → pam_python-0.1.20}/pam/temp_file_utils.py +0 -0
  18. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/buildcmd/pamb +0 -0
  19. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/buildcmd/pamb-base.sh +0 -0
  20. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/docker/Dockerfile +0 -0
  21. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/init/dockerignore.tmpl +0 -0
  22. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/init/gitignore.tmpl +0 -0
  23. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/init/main.tmpl +0 -0
  24. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/init/pylintrc.tmpl +0 -0
  25. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/init/run_test.sh +0 -0
  26. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/service/functions.tmpl +0 -0
  27. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/service/service.test.tmpl +0 -0
  28. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/service/service.yaml +0 -0
  29. {pam_python-0.1.18 → pam_python-0.1.20}/pam/templates/service/service_class.tmpl +0 -0
  30. {pam_python-0.1.18 → pam_python-0.1.20}/pam/tester_task.py +0 -0
  31. {pam_python-0.1.18 → pam_python-0.1.20}/pam/utils.py +0 -0
  32. {pam_python-0.1.18 → pam_python-0.1.20}/pam_python.egg-info/dependency_links.txt +0 -0
  33. {pam_python-0.1.18 → pam_python-0.1.20}/pam_python.egg-info/entry_points.txt +0 -0
  34. {pam_python-0.1.18 → pam_python-0.1.20}/pam_python.egg-info/requires.txt +0 -0
  35. {pam_python-0.1.18 → pam_python-0.1.20}/pam_python.egg-info/top_level.txt +0 -0
  36. {pam_python-0.1.18 → pam_python-0.1.20}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pam-python
3
- Version: 0.1.18
3
+ Version: 0.1.20
4
4
  Summary: Pam Python Library
5
5
  Home-page: https://github.com/heart/pam-python
6
6
  Author: Narongrit Kanhanoi
@@ -97,7 +97,7 @@ class Service:
97
97
 
98
98
  return report_csv_path
99
99
 
100
- def _request_sqlite(self, file_name: str = "", is_shared: bool = False) -> str | None:
100
+ def _request_sqlite(self, file_name: str = "", is_shared: bool = False) -> str:
101
101
  """Requests last sqlite file that this plugin has uploaded from the last time.
102
102
 
103
103
  Returns:
@@ -129,7 +129,7 @@ class Service:
129
129
  return output_path
130
130
  else:
131
131
  log(f"{self.request.service_name}: Failed to download SQLite file.")
132
- return None
132
+ return output_path
133
133
 
134
134
 
135
135
  def _upload_sqlite(self, file_name: str = "", is_shared: bool = False, sqlite_file: str = "") -> str:
@@ -0,0 +1,75 @@
1
+ import sqlite3
2
+ from pam.utils import log
3
+ from typing import Any, List, Optional, Tuple, Union
4
+
5
+ class SQLiteDB:
6
+ def __init__(self, db_path: str, row_as_dict: bool = False, timeout=30):
7
+ """
8
+ Initialize the SQLiteDB wrapper.
9
+
10
+ :param db_path: Path to the SQLite database file.
11
+ :param row_as_dict: If True, fetches rows as dictionaries.
12
+ """
13
+ self.db_path = db_path
14
+ self.row_as_dict = row_as_dict
15
+ self.timeout = timeout
16
+ self.conn = sqlite3.connect(db_path, timeout)
17
+ if row_as_dict:
18
+ self.conn.row_factory = sqlite3.Row
19
+
20
+ def __enter__(self):
21
+ return self
22
+
23
+ def __exit__(self, exc_type, exc_val, exc_tb):
24
+ self.close()
25
+
26
+ def execute(self, query: str, params: Optional[Tuple[Any, ...]] = None) -> None:
27
+ """Execute a write query (INSERT/UPDATE/DELETE)."""
28
+ try:
29
+ with self.conn:
30
+ self.conn.execute(query, params or ())
31
+ except sqlite3.Error as e:
32
+ log(f"SQLite execute error: {e}")
33
+ raise
34
+
35
+ def executemany(self, query: str, data: List[Tuple[Any, ...]]) -> None:
36
+ """Execute a batch write query."""
37
+ try:
38
+ with self.conn:
39
+ self.conn.executemany(query, data)
40
+ except sqlite3.Error as e:
41
+ log(f"SQLite executemany error: {e}")
42
+ raise
43
+
44
+ def fetchall(self, query: str, params: Optional[Tuple[Any, ...]] = None) -> List[Union[Tuple, dict]]:
45
+ """Fetch all results from a SELECT query."""
46
+ try:
47
+ cursor = self.conn.execute(query, params or ())
48
+ return cursor.fetchall()
49
+ except sqlite3.Error as e:
50
+ log(f"SQLite fetchall error: {e}")
51
+ raise
52
+
53
+ def fetchone(self, query: str, params: Optional[Tuple[Any, ...]] = None) -> Optional[Union[Tuple, dict]]:
54
+ """Fetch the first result from a SELECT query."""
55
+ try:
56
+ cursor = self.conn.execute(query, params or ())
57
+ return cursor.fetchone()
58
+ except sqlite3.Error as e:
59
+ log(f"SQLite fetchone error: {e}")
60
+ raise
61
+
62
+ def create_table(self, create_sql: str) -> None:
63
+ """Create a table from a SQL string."""
64
+ try:
65
+ with self.conn:
66
+ self.conn.execute(create_sql)
67
+ except sqlite3.Error as e:
68
+ log(f"SQLite create_table error: {e}")
69
+ raise
70
+
71
+ def close(self) -> None:
72
+ """Close the connection."""
73
+ if self.conn:
74
+ self.conn.close()
75
+ log("SQLite connection closed.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pam-python
3
- Version: 0.1.18
3
+ Version: 0.1.20
4
4
  Summary: Pam Python Library
5
5
  Home-page: https://github.com/heart/pam-python
6
6
  Author: Narongrit Kanhanoi
@@ -7,6 +7,7 @@ pam/cli.py
7
7
  pam/interface_task_manager.py
8
8
  pam/server.py
9
9
  pam/service.py
10
+ pam/sqlite.py
10
11
  pam/task_manager.py
11
12
  pam/temp_file_utils.py
12
13
  pam/tester_task.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="pam-python",
5
- version="0.1.18",
5
+ version="0.1.20",
6
6
  author="Narongrit Kanhanoi",
7
7
  author_email="narongrit@pams.ai",
8
8
  description="Pam Python Library",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes