checkmate5 4.0.92__py3-none-any.whl → 4.0.93__py3-none-any.whl
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.
- checkmate/lib/backend.py +119 -0
- checkmate/management/helpers.py +1 -1
- {checkmate5-4.0.92.dist-info → checkmate5-4.0.93.dist-info}/METADATA +1 -1
- {checkmate5-4.0.92.dist-info → checkmate5-4.0.93.dist-info}/RECORD +8 -7
- {checkmate5-4.0.92.dist-info → checkmate5-4.0.93.dist-info}/LICENSE.txt +0 -0
- {checkmate5-4.0.92.dist-info → checkmate5-4.0.93.dist-info}/WHEEL +0 -0
- {checkmate5-4.0.92.dist-info → checkmate5-4.0.93.dist-info}/entry_points.txt +0 -0
- {checkmate5-4.0.92.dist-info → checkmate5-4.0.93.dist-info}/top_level.txt +0 -0
checkmate/lib/backend.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
from blitzdb import FileBackend as BlitzDBFileBackend
|
|
2
|
+
from blitzdb.backends.sql import Backend as BlitzDBSQLBackend
|
|
3
|
+
from typing import Any, Optional, Dict
|
|
4
|
+
import logging
|
|
5
|
+
from contextlib import contextmanager
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
class FileBackend(BlitzDBFileBackend):
|
|
10
|
+
def __init__(self, path: str) -> None:
|
|
11
|
+
"""Initialize FileBackend with specified path.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
path: Path to store the database files
|
|
15
|
+
|
|
16
|
+
Raises:
|
|
17
|
+
ValueError: If path is invalid
|
|
18
|
+
"""
|
|
19
|
+
logger.debug(f"Initializing FileBackend with path: {path}")
|
|
20
|
+
super().__init__(path)
|
|
21
|
+
self.path = path
|
|
22
|
+
|
|
23
|
+
def test_connection(self) -> bool:
|
|
24
|
+
"""Test the file access.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
bool: True if file access is successful
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
ConnectionError: If file access test fails
|
|
31
|
+
"""
|
|
32
|
+
try:
|
|
33
|
+
self.begin()
|
|
34
|
+
self.commit()
|
|
35
|
+
logger.info("File access test successful")
|
|
36
|
+
return True
|
|
37
|
+
except Exception as e:
|
|
38
|
+
logger.error(f"File access test failed: {str(e)}")
|
|
39
|
+
raise ConnectionError(f"File access test failed: {str(e)}")
|
|
40
|
+
|
|
41
|
+
@contextmanager
|
|
42
|
+
def session(self):
|
|
43
|
+
"""Context manager for file operations.
|
|
44
|
+
|
|
45
|
+
Yields:
|
|
46
|
+
FileBackend: Self with active session
|
|
47
|
+
"""
|
|
48
|
+
try:
|
|
49
|
+
self.begin()
|
|
50
|
+
yield self
|
|
51
|
+
self.commit()
|
|
52
|
+
except Exception as e:
|
|
53
|
+
logger.error(f"Session error: {str(e)}")
|
|
54
|
+
self.rollback()
|
|
55
|
+
raise
|
|
56
|
+
|
|
57
|
+
class SQLBackend(BlitzDBSQLBackend):
|
|
58
|
+
def __init__(self, connection: Any) -> None:
|
|
59
|
+
"""Initialize SQL Backend with database connection.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
connection: SQLAlchemy engine or connection object
|
|
63
|
+
|
|
64
|
+
Raises:
|
|
65
|
+
ConnectionError: If database connection fails
|
|
66
|
+
"""
|
|
67
|
+
logger.debug(f"Initializing SQL Backend with connection: {connection}")
|
|
68
|
+
super().__init__(connection)
|
|
69
|
+
self.connection = connection
|
|
70
|
+
|
|
71
|
+
def test_connection(self) -> bool:
|
|
72
|
+
"""Test the database connection.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
bool: True if connection is successful
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
ConnectionError: If connection test fails
|
|
79
|
+
"""
|
|
80
|
+
try:
|
|
81
|
+
with self.connection.connect() as conn:
|
|
82
|
+
conn.execute('SELECT 1')
|
|
83
|
+
logger.info("Database connection test successful")
|
|
84
|
+
return True
|
|
85
|
+
except Exception as e:
|
|
86
|
+
logger.error(f"Database connection test failed: {str(e)}")
|
|
87
|
+
raise ConnectionError(f"Database connection test failed: {str(e)}")
|
|
88
|
+
|
|
89
|
+
@contextmanager
|
|
90
|
+
def session(self):
|
|
91
|
+
"""Context manager for database sessions.
|
|
92
|
+
|
|
93
|
+
Yields:
|
|
94
|
+
SQLBackend: Self with active session
|
|
95
|
+
"""
|
|
96
|
+
try:
|
|
97
|
+
self.begin()
|
|
98
|
+
yield self
|
|
99
|
+
self.commit()
|
|
100
|
+
except Exception as e:
|
|
101
|
+
logger.error(f"Session error: {str(e)}")
|
|
102
|
+
self.rollback()
|
|
103
|
+
raise
|
|
104
|
+
finally:
|
|
105
|
+
if hasattr(self.connection, 'dispose'):
|
|
106
|
+
self.connection.dispose()
|
|
107
|
+
|
|
108
|
+
def close(self) -> None:
|
|
109
|
+
"""Clean up database connections."""
|
|
110
|
+
try:
|
|
111
|
+
if hasattr(self.connection, 'dispose'):
|
|
112
|
+
self.connection.dispose()
|
|
113
|
+
logger.info("Closed SQL Backend connection")
|
|
114
|
+
except Exception as e:
|
|
115
|
+
logger.error(f"Error closing backend: {str(e)}")
|
|
116
|
+
raise
|
|
117
|
+
|
|
118
|
+
# For backward compatibility
|
|
119
|
+
Backend = SQLBackend # Default to SQLBackend for existing code
|
checkmate/management/helpers.py
CHANGED
|
@@ -9,7 +9,7 @@ from functools import reduce
|
|
|
9
9
|
import argparse
|
|
10
10
|
from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String
|
|
11
11
|
from sqlalchemy.exc import SQLAlchemyError
|
|
12
|
-
from
|
|
12
|
+
from checkmate.lib.backend import Backend
|
|
13
13
|
|
|
14
14
|
def get_project_path(path=None):
|
|
15
15
|
if not path:
|
|
@@ -71,6 +71,7 @@ checkmate/helpers/hashing.py,sha256=TcwBFJlciJkLlETQcQBxEWRgwyh2HK9MO4BzN2VMlDU,
|
|
|
71
71
|
checkmate/helpers/issue.py,sha256=7wImtI8uZR5VcE_1u7mI8qvEXU97p6Rzkb1bbJkqXKQ,3841
|
|
72
72
|
checkmate/helpers/settings.py,sha256=97zsz4vNq7EpUpRME4XQvvp5LUp3618ZvSfNTce_4j4,322
|
|
73
73
|
checkmate/lib/__init__.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
|
|
74
|
+
checkmate/lib/backend.py,sha256=dO3rMqI70D8-9CrgL3qu3fqKf0BXvJCDIgSIys8IRyM,3683
|
|
74
75
|
checkmate/lib/models.py,sha256=Myzjf7ChJnObPpMLXv34znMXkeP0Fma54iUN9uSl8AI,20191
|
|
75
76
|
checkmate/lib/analysis/__init__.py,sha256=_JpM1GkChWCfLKqPqEz3-8DCPwNe7lPwQDMoF_6Ore0,45
|
|
76
77
|
checkmate/lib/analysis/base.py,sha256=R9Zy6rKKCw1LSAsBBBaBbgFEo6Fkdx8DTtp7bsYoywE,3309
|
|
@@ -81,7 +82,7 @@ checkmate/lib/stats/helpers.py,sha256=X21Pb7dz3PWubDRoqUjbxwonl43TRxqKEcwyM80tS6
|
|
|
81
82
|
checkmate/lib/stats/mapreduce.py,sha256=rGdA_HninEZSeowtBn5R02c6wyT5dxcu-0T2ftlMnY0,782
|
|
82
83
|
checkmate/management/__init__.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
|
|
83
84
|
checkmate/management/decorators.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
|
|
84
|
-
checkmate/management/helpers.py,sha256=
|
|
85
|
+
checkmate/management/helpers.py,sha256=8AQ2qNBBJ16H4T4G5FolH9RhdLQ1adVdzxrkLEaxcsU,5411
|
|
85
86
|
checkmate/management/commands/__init__.py,sha256=XAi0y8z1NviyGvLB68Oxnzr6Nw5AP8xgbcSSnc1Zcvw,766
|
|
86
87
|
checkmate/management/commands/alembic.py,sha256=DTWH8hcY6UmWDo0wMwcID_wQIa-es7nyJHV6p1_T4FQ,718
|
|
87
88
|
checkmate/management/commands/analyze.py,sha256=J1rawVEGjbrXT9ArfUVpfoLNs2JaFkV4mCrBnEIrXaw,1159
|
|
@@ -109,9 +110,9 @@ checkmate/scripts/manage.py,sha256=mpioBaxzirAKXZtbxO-y4dbOcc6UoP0MaAMsNuKHbz0,4
|
|
|
109
110
|
checkmate/settings/__init__.py,sha256=z32hPz-kGS-tTGa6dWCFjrrrbS_eagLd-YrqBP3gjWI,33
|
|
110
111
|
checkmate/settings/base.py,sha256=3WBXZITqoWepIja96bo5JTi-TDpQALPTCugL0E8z-yE,4551
|
|
111
112
|
checkmate/settings/defaults.py,sha256=HJoZIin2BHT_gBCngGZNh7WgSNLqIDTK--iW7hXez4Q,5084
|
|
112
|
-
checkmate5-4.0.
|
|
113
|
-
checkmate5-4.0.
|
|
114
|
-
checkmate5-4.0.
|
|
115
|
-
checkmate5-4.0.
|
|
116
|
-
checkmate5-4.0.
|
|
117
|
-
checkmate5-4.0.
|
|
113
|
+
checkmate5-4.0.93.dist-info/LICENSE.txt,sha256=9cSf5btiPmglu3yzhXkXcf7GNT8XC9o7Y54tfhvfDp8,213739
|
|
114
|
+
checkmate5-4.0.93.dist-info/METADATA,sha256=aTicVld8Hcve_pknVkSm8KttlJgOF5HL_tp748EJoqc,1234
|
|
115
|
+
checkmate5-4.0.93.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
116
|
+
checkmate5-4.0.93.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
|
|
117
|
+
checkmate5-4.0.93.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
|
|
118
|
+
checkmate5-4.0.93.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|