checkmate5 4.1.0.dev34__py3-none-any.whl → 4.1.0.dev35__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 CHANGED
@@ -6,4 +6,67 @@ from ..helpers.exceptions import DatabaseError
6
6
 
7
7
  logger = logging.getLogger(__name__)
8
8
 
9
- Backend = BlitzDBSQLBackend
9
+
10
+ class SQLBackend(BlitzDBSQLBackend):
11
+ def __init__(self, connection: Any) -> None:
12
+ """Initialize SQL Backend with database connection.
13
+
14
+ Args:
15
+ connection: SQLAlchemy engine or connection object
16
+
17
+ Raises:
18
+ ConnectionError: If database connection fails
19
+ """
20
+ logger.debug(f"Initializing SQL Backend with connection: {connection}")
21
+ super().__init__(connection)
22
+ self.connection = connection
23
+
24
+ def test_connection(self) -> bool:
25
+ """Test the database connection.
26
+
27
+ Returns:
28
+ bool: True if connection is successful
29
+
30
+ Raises:
31
+ ConnectionError: If connection test fails
32
+ """
33
+ try:
34
+ with self.connection.connect() as conn:
35
+ conn.execute('SELECT 1')
36
+ logger.info("Database connection test successful")
37
+ return True
38
+ except Exception as e:
39
+ logger.error(f"Database connection test failed: {str(e)}")
40
+ raise ConnectionError(f"Database connection test failed: {str(e)}")
41
+
42
+ @contextmanager
43
+ def session(self):
44
+ """Context manager for database sessions.
45
+
46
+ Yields:
47
+ SQLBackend: Self with active session
48
+ """
49
+ try:
50
+ self.begin()
51
+ yield self
52
+ self.commit()
53
+ except Exception as e:
54
+ logger.error(f"Session error: {str(e)}")
55
+ self.rollback()
56
+ raise
57
+ finally:
58
+ if hasattr(self.connection, 'dispose'):
59
+ self.connection.dispose()
60
+
61
+ def close(self) -> None:
62
+ """Clean up database connections."""
63
+ try:
64
+ if hasattr(self.connection, 'dispose'):
65
+ self.connection.dispose()
66
+ logger.info("Closed SQL Backend connection")
67
+ except Exception as e:
68
+ logger.error(f"Error closing backend: {str(e)}")
69
+ raise
70
+
71
+ # For backward compatibility
72
+ Backend = SQLBackend # Default to SQLBackend for existing code
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: checkmate5
3
- Version: 4.1.0.dev34
3
+ Version: 4.1.0.dev35
4
4
  Summary: A meta-code checker written in Python.
5
5
  Author: Andreas Dewes
6
6
  License: AGPL-3.0
@@ -72,7 +72,7 @@ checkmate/helpers/hashing.py,sha256=TcwBFJlciJkLlETQcQBxEWRgwyh2HK9MO4BzN2VMlDU,
72
72
  checkmate/helpers/issue.py,sha256=7wImtI8uZR5VcE_1u7mI8qvEXU97p6Rzkb1bbJkqXKQ,3841
73
73
  checkmate/helpers/settings.py,sha256=97zsz4vNq7EpUpRME4XQvvp5LUp3618ZvSfNTce_4j4,322
74
74
  checkmate/lib/__init__.py,sha256=iwhKnzeBJLKxpRVjvzwiRE63_zNpIBfaKLITauVph-0,24
75
- checkmate/lib/backend.py,sha256=7302LiR5NTaePEsBDxdIHUFqMfnzvMKZi4SyZ7Mc8ms,268
75
+ checkmate/lib/backend.py,sha256=_mMw7snfCdjiy3Hh0buSJt2AXFB-SP09-Xbx1YzG2PU,2305
76
76
  checkmate/lib/models.py,sha256=bmS_QDDBEMaqC0TiKNaoRBCHuVUK9S-TSBB7BYYJz7Q,7404
77
77
  checkmate/lib/analysis/__init__.py,sha256=_JpM1GkChWCfLKqPqEz3-8DCPwNe7lPwQDMoF_6Ore0,45
78
78
  checkmate/lib/analysis/base.py,sha256=R9Zy6rKKCw1LSAsBBBaBbgFEo6Fkdx8DTtp7bsYoywE,3309
@@ -111,9 +111,9 @@ checkmate/scripts/manage.py,sha256=mpioBaxzirAKXZtbxO-y4dbOcc6UoP0MaAMsNuKHbz0,4
111
111
  checkmate/settings/__init__.py,sha256=z32hPz-kGS-tTGa6dWCFjrrrbS_eagLd-YrqBP3gjWI,33
112
112
  checkmate/settings/base.py,sha256=3WBXZITqoWepIja96bo5JTi-TDpQALPTCugL0E8z-yE,4551
113
113
  checkmate/settings/defaults.py,sha256=uK1KB50ukDbk2rACyiCQuXTNSr2M7GXE-2_GTFupbv0,2728
114
- checkmate5-4.1.0.dev34.dist-info/licenses/LICENSE.txt,sha256=SGQTFjJQjkYGoK1PCFfMKpfgRLm3yL0h9Mq2o26sm2E,151451
115
- checkmate5-4.1.0.dev34.dist-info/METADATA,sha256=mx1GYxnsddRZAcS5nqS1auVwGWgiVRBkfQhtq3vBZok,1262
116
- checkmate5-4.1.0.dev34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
117
- checkmate5-4.1.0.dev34.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
118
- checkmate5-4.1.0.dev34.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
119
- checkmate5-4.1.0.dev34.dist-info/RECORD,,
114
+ checkmate5-4.1.0.dev35.dist-info/licenses/LICENSE.txt,sha256=SGQTFjJQjkYGoK1PCFfMKpfgRLm3yL0h9Mq2o26sm2E,151451
115
+ checkmate5-4.1.0.dev35.dist-info/METADATA,sha256=Nu3r4Pc3ssTK_s65lAfuPCVJrelvwlDqoOZNf0TL_8U,1262
116
+ checkmate5-4.1.0.dev35.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
117
+ checkmate5-4.1.0.dev35.dist-info/entry_points.txt,sha256=FbGnau5C4z98WmBYpMJqUzobQEr1AIi9aZApSavNojQ,60
118
+ checkmate5-4.1.0.dev35.dist-info/top_level.txt,sha256=tl6eIJXedpLZbcbmYEwlhEzuTaSt0TvIRUesOb8gtng,10
119
+ checkmate5-4.1.0.dev35.dist-info/RECORD,,